File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,11 +26,10 @@ mock.module("node:os", () => ({
2626} ) ) ;
2727
2828describe ( "formatDate" , ( ) => {
29- test ( "formats UTC timestamp to JST date" , ( ) => {
30- // UTC midnight = JST 9 AM
29+ test ( "formats UTC timestamp to local date" , ( ) => {
30+ // Test with UTC timestamps - results depend on local timezone
3131 expect ( formatDate ( "2024-01-01T00:00:00Z" ) ) . toBe ( "2024-01-01" ) ;
32- // UTC 3 PM = JST midnight next day
33- expect ( formatDate ( "2024-01-01T15:00:00Z" ) ) . toBe ( "2024-01-02" ) ;
32+ expect ( formatDate ( "2024-01-01T15:00:00Z" ) ) . toBe ( "2024-01-01" ) ;
3433 } ) ;
3534
3635 test ( "handles various date formats" , ( ) => {
Original file line number Diff line number Diff line change @@ -39,10 +39,9 @@ export type SessionUsage = v.InferOutput<typeof SessionUsageSchema>;
3939
4040export const formatDate = ( dateStr : string ) : string => {
4141 const date = new Date ( dateStr ) ;
42- const offsetDate = new Date ( date . getTime ( ) + 9 * 60 * 60 * 1000 ) ; // UTC+9 for JST
43- const year = offsetDate . getUTCFullYear ( ) ;
44- const month = String ( offsetDate . getUTCMonth ( ) + 1 ) . padStart ( 2 , "0" ) ;
45- const day = String ( offsetDate . getUTCDate ( ) ) . padStart ( 2 , "0" ) ;
42+ const year = date . getFullYear ( ) ;
43+ const month = String ( date . getMonth ( ) + 1 ) . padStart ( 2 , "0" ) ;
44+ const day = String ( date . getDate ( ) ) . padStart ( 2 , "0" ) ;
4645 return `${ year } -${ month } -${ day } ` ;
4746} ;
4847
You can’t perform that action at this time.
0 commit comments