@@ -7,37 +7,37 @@ import * as chrono from 'chrono-node'
77import { format , isThisYear , isValid } from 'date-fns'
88import { formatInTimeZone } from 'date-fns-tz'
99
10- const LOCAL_LOG_STYLE_DATE_FORMATTER = new Intl . DateTimeFormat ( undefined , {
10+ const LOCAL_LOG_STYLE_DATE_FORMATTER = new Intl . DateTimeFormat ( 'en-US' , {
1111 month : 'short' ,
1212 day : '2-digit' ,
1313} )
1414
1515const LOCAL_LOG_STYLE_DATE_WITH_YEAR_FORMATTER = new Intl . DateTimeFormat (
16- undefined ,
16+ 'en-US' ,
1717 {
1818 month : 'short' ,
1919 day : '2-digit' ,
2020 year : 'numeric' ,
2121 }
2222)
2323
24- const LOCAL_LOG_STYLE_TIME_FORMATTER = new Intl . DateTimeFormat ( undefined , {
24+ const LOCAL_LOG_STYLE_TIME_FORMATTER = new Intl . DateTimeFormat ( 'en-US' , {
2525 hour : '2-digit' ,
2626 minute : '2-digit' ,
2727 second : '2-digit' ,
2828 hour12 : false ,
2929} )
3030
3131const LOCAL_LOG_STYLE_TIME_NO_SECONDS_FORMATTER = new Intl . DateTimeFormat (
32- undefined ,
32+ 'en-US' ,
3333 {
3434 hour : '2-digit' ,
3535 minute : '2-digit' ,
3636 hour12 : false ,
3737 }
3838)
3939
40- const LOCAL_LOG_STYLE_TIMEZONE_FORMATTER = new Intl . DateTimeFormat ( undefined , {
40+ const LOCAL_LOG_STYLE_TIMEZONE_FORMATTER = new Intl . DateTimeFormat ( 'en-US' , {
4141 timeZoneName : 'short' ,
4242} )
4343
@@ -55,16 +55,18 @@ export function formatLocalLogStyleTimestamp(
5555 includeSeconds = true ,
5656 includeYear = false ,
5757 includeCentiseconds = false ,
58+ includeTimezone = false ,
5859 } : {
5960 includeSeconds ?: boolean
6061 includeYear ?: boolean
6162 includeCentiseconds ?: boolean
63+ includeTimezone ?: boolean
6264 } = { }
6365) : {
6466 datePart : string
6567 timePart : string
6668 subsecondPart : string | null
67- timezonePart : string
69+ timezonePart : string | null
6870 iso : string
6971} | null {
7072 const date = new Date ( timestamp )
@@ -73,12 +75,13 @@ export function formatLocalLogStyleTimestamp(
7375 return null
7476 }
7577
76- const timezonePart =
77- LOCAL_LOG_STYLE_TIMEZONE_FORMATTER . formatToParts ( date ) . find (
78- ( part ) => part . type === 'timeZoneName'
79- ) ?. value ??
80- Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone ??
81- 'Local'
78+ const timezonePart = includeTimezone
79+ ? ( LOCAL_LOG_STYLE_TIMEZONE_FORMATTER . formatToParts ( date ) . find (
80+ ( part ) => part . type === 'timeZoneName'
81+ ) ?. value ??
82+ Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone ??
83+ 'Local' )
84+ : null
8285
8386 return {
8487 datePart : ( includeYear
@@ -148,8 +151,8 @@ export const formatDisplayTimestamp = (value: string | number | Date) => {
148151 ? 'Today'
149152 : isYesterday
150153 ? 'Yesterday'
151- : date . toLocaleDateString ( )
152- const timeStr = date . toLocaleTimeString ( [ ] , {
154+ : date . toLocaleDateString ( 'en-US' )
155+ const timeStr = date . toLocaleTimeString ( 'en-US' , {
153156 hour : 'numeric' ,
154157 minute : '2-digit' ,
155158 second : '2-digit' ,
0 commit comments