@@ -11,6 +11,7 @@ const {
1111 getBytesSent,
1212 calculateTotalTime,
1313 calculateTurnAroundTime,
14+ timestampToDateTime643,
1415} = require ( '../../../lib/utilities/serverAccessLogger' ) ;
1516
1617
@@ -618,6 +619,48 @@ describe('serverAccessLogger utility functions', () => {
618619 } ) ;
619620 } ) ;
620621
622+ describe ( 'timestampToDateTime643' , ( ) => {
623+ it ( 'should convert milliseconds to seconds with 3 decimal places' , ( ) => {
624+ const startTimeUnixMS = 1234567890000 ;
625+ const result = timestampToDateTime643 ( startTimeUnixMS ) ;
626+ assert . strictEqual ( result , '1234567890.000' ) ;
627+ } ) ;
628+
629+ it ( 'should handle timestamp with milliseconds' , ( ) => {
630+ const startTimeUnixMS = 1234567890123 ;
631+ const result = timestampToDateTime643 ( startTimeUnixMS ) ;
632+ assert . strictEqual ( result , '1234567890.123' ) ;
633+ } ) ;
634+
635+ it ( 'should handle 0' , ( ) => {
636+ const startTimeUnixMS = 0 ;
637+ const result = timestampToDateTime643 ( startTimeUnixMS ) ;
638+ assert . strictEqual ( result , '0.000' ) ;
639+ } ) ;
640+
641+ it ( 'should return null when startTimeUnixMS is null' , ( ) => {
642+ const result = timestampToDateTime643 ( null ) ;
643+ assert . strictEqual ( result , null ) ;
644+ } ) ;
645+
646+ it ( 'should return null when startTimeUnixMS is undefined' , ( ) => {
647+ const result = timestampToDateTime643 ( undefined ) ;
648+ assert . strictEqual ( result , null ) ;
649+ } ) ;
650+
651+ it ( 'should handle small timestamps' , ( ) => {
652+ const startTimeUnixMS = 1000 ;
653+ const result = timestampToDateTime643 ( startTimeUnixMS ) ;
654+ assert . strictEqual ( result , '1.000' ) ;
655+ } ) ;
656+
657+ it ( 'should handle timestamps with partial milliseconds' , ( ) => {
658+ const startTimeUnixMS = 1500 ;
659+ const result = timestampToDateTime643 ( startTimeUnixMS ) ;
660+ assert . strictEqual ( result , '1.500' ) ;
661+ } ) ;
662+ } ) ;
663+
621664 describe ( 'logServerAccess' , ( ) => {
622665 let mockLogger ;
623666 let sandbox ;
@@ -773,7 +816,7 @@ describe('serverAccessLogger utility functions', () => {
773816 assert . strictEqual ( loggedData . httpURL , '/test-bucket/test-key.txt' ) ;
774817
775818 // Verify AWS access server log fields
776- assert . strictEqual ( loggedData . startTime , 1234567890000 ) ;
819+ assert . strictEqual ( loggedData . startTime , '1234567890.000' ) ;
777820 assert . strictEqual ( loggedData . requester , 'canonical123' ) ;
778821 assert . strictEqual ( loggedData . operation , 'REST.GET.OBJECT' ) ;
779822 assert . strictEqual ( loggedData . requestURI , 'GET /test-bucket/test-key.txt HTTP/1.1' ) ;
0 commit comments