11import type { SandboxLogModel } from '@/core/modules/sandboxes/models'
22import { LogLevelBadge } from '@/features/dashboard/common/log-cells'
3+ import { formatLocalLogStyleTimestamp } from '@/lib/utils/formatting'
34import CopyButtonInline from '@/ui/copy-button-inline'
45
5- const LOCAL_DATE_FORMATTER = new Intl . DateTimeFormat ( undefined , {
6- month : 'short' ,
7- day : '2-digit' ,
8- } )
9-
10- const LOCAL_TIME_FORMATTER = new Intl . DateTimeFormat ( undefined , {
11- hour : '2-digit' ,
12- minute : '2-digit' ,
13- second : '2-digit' ,
14- hour12 : false ,
15- } )
16-
176export const LogLevel = ( { level } : { level : SandboxLogModel [ 'level' ] } ) => {
187 return < LogLevelBadge level = { level } />
198}
@@ -23,21 +12,21 @@ interface TimestampProps {
2312}
2413
2514export const Timestamp = ( { timestampUnix } : TimestampProps ) => {
26- const date = new Date ( timestampUnix )
15+ const formatted = formatLocalLogStyleTimestamp ( timestampUnix , {
16+ includeCentiseconds : true ,
17+ } )
2718
28- const centiseconds = Math . floor ( ( date . getMilliseconds ( ) / 10 ) % 100 )
29- . toString ( )
30- . padStart ( 2 , '0' )
31- const localDatePart = LOCAL_DATE_FORMATTER . format ( date )
32- const localTimePart = LOCAL_TIME_FORMATTER . format ( date )
19+ if ( ! formatted ) {
20+ return < span className = "font-mono prose-table-numeric" > --</ span >
21+ }
3322
3423 return (
3524 < CopyButtonInline
36- value = { date . toISOString ( ) }
25+ value = { formatted . iso }
3726 className = "font-mono group prose-table-numeric truncate"
3827 >
39- < span className = "text-fg-tertiary" > { localDatePart } </ span > { localTimePart } .
40- { centiseconds }
28+ < span className = "text-fg-tertiary" > { formatted . datePart } </ span > { ' ' }
29+ { formatted . timePart } . { formatted . subsecondPart }
4130 </ CopyButtonInline >
4231 )
4332}
0 commit comments