@@ -8,7 +8,7 @@ import { renderStatusBar } from './format.js'
88import { type PeriodData , type ProviderCost } from './menubar-json.js'
99import { buildMenubarPayload } from './menubar-json.js'
1010import { addNewDays , getDaysInRange , loadDailyCache , saveDailyCache , withDailyCacheLock } from './daily-cache.js'
11- import { aggregateProjectsIntoDays , buildPeriodDataFromDays } from './day-aggregator.js'
11+ import { aggregateProjectsIntoDays , buildPeriodDataFromDays , dateKey } from './day-aggregator.js'
1212import { CATEGORY_LABELS , type DateRange , type ProjectSummary , type TaskCategory } from './types.js'
1313import { renderDashboard } from './dashboard.js'
1414import { parseDateRangeFlags } from './cli-date.js'
@@ -25,7 +25,7 @@ const MS_PER_DAY = 24 * 60 * 60 * 1000
2525const BACKFILL_DAYS = 365
2626
2727function toDateString ( date : Date ) : string {
28- return date . toISOString ( ) . slice ( 0 , 10 )
28+ return ` ${ date . getFullYear ( ) } - ${ String ( date . getMonth ( ) + 1 ) . padStart ( 2 , '0' ) } - ${ String ( date . getDate ( ) ) . padStart ( 2 , '0' ) } `
2929}
3030
3131function getDateRange ( period : string ) : { range : DateRange ; label : string } {
@@ -35,12 +35,12 @@ function getDateRange(period: string): { range: DateRange; label: string } {
3535 switch ( period ) {
3636 case 'today' : {
3737 const start = new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) )
38- return { range : { start, end } , label : `Today (${ start . toISOString ( ) . slice ( 0 , 10 ) } )` }
38+ return { range : { start, end } , label : `Today (${ toDateString ( start ) } )` }
3939 }
4040 case 'yesterday' : {
4141 const start = new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) - 1 )
4242 const yesterdayEnd = new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) - 1 , 23 , 59 , 59 , 999 )
43- return { range : { start, end : yesterdayEnd } , label : `Yesterday (${ start . toISOString ( ) . slice ( 0 , 10 ) } )` }
43+ return { range : { start, end : yesterdayEnd } , label : `Yesterday (${ toDateString ( start ) } )` }
4444 }
4545 case 'week' : {
4646 const start = new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) - 7 )
@@ -123,7 +123,7 @@ function buildJsonReport(projects: ProjectSummary[], period: string, periodKey:
123123 for ( const sess of sessions ) {
124124 for ( const turn of sess . turns ) {
125125 if ( ! turn . timestamp ) { continue }
126- const day = turn . timestamp . slice ( 0 , 10 )
126+ const day = dateKey ( turn . timestamp )
127127 if ( ! dailyMap [ day ] ) { dailyMap [ day ] = { cost : 0 , calls : 0 } }
128128 for ( const call of turn . assistantCalls ) {
129129 dailyMap [ day ] . cost += call . costUSD
@@ -204,7 +204,7 @@ function buildJsonReport(projects: ProjectSummary[], period: string, periodKey:
204204 Object . entries ( m ) . sort ( ( [ , a ] , [ , b ] ) => b - a ) . map ( ( [ name , calls ] ) => ( { name, calls } ) )
205205
206206 const topSessions = projects
207- . flatMap ( p => p . sessions . map ( s => ( { project : p . project , sessionId : s . sessionId , date : s . firstTimestamp ?. slice ( 0 , 10 ) ?? null , cost : convertCost ( s . totalCostUSD ) , calls : s . apiCalls } ) ) )
207+ . flatMap ( p => p . sessions . map ( s => ( { project : p . project , sessionId : s . sessionId , date : s . firstTimestamp ? dateKey ( s . firstTimestamp ) : null , cost : convertCost ( s . totalCostUSD ) , calls : s . apiCalls } ) ) )
208208 . sort ( ( a , b ) => b . cost - a . cost )
209209 . slice ( 0 , 5 )
210210
@@ -545,7 +545,7 @@ program
545545 return
546546 }
547547
548- const defaultName = `codeburn-${ new Date ( ) . toISOString ( ) . slice ( 0 , 10 ) } `
548+ const defaultName = `codeburn-${ toDateString ( new Date ( ) ) } `
549549 const outputPath = opts . output ?? `${ defaultName } .${ opts . format } `
550550
551551 let savedPath : string
0 commit comments