@@ -406,28 +406,44 @@ public void TimestampTokenRendersLocalTime()
406406 {
407407 var logTimestampWithTimeZoneOffset = DateTimeOffset . Parse ( "2024-09-03T14:15:16.079+02:00" , CultureInfo . InvariantCulture ) ;
408408 var formatter = new OutputTemplateRenderer ( ConsoleTheme . None ,
409- "Default Format: {Timestamp} / Custom Format String: {Timestamp:yyyy-MM-dd HH:mm:ss}" ,
409+ """
410+ Default Format: {Timestamp}
411+ Round-trip Standard Format String: {Timestamp:o}
412+ Custom Format String: {Timestamp:yyyy-MM-dd HH:mm:ss}
413+ """ ,
410414 CultureInfo . InvariantCulture ) ;
411415 var evt = new LogEvent ( logTimestampWithTimeZoneOffset , LogEventLevel . Debug , null ,
412416 new MessageTemplate ( Enumerable . Empty < MessageTemplateToken > ( ) ) , Enumerable . Empty < LogEventProperty > ( ) ) ;
413417 var sw = new StringWriter ( ) ;
414418 formatter . Format ( evt , sw ) ;
415419 // expect time in local time, unchanged from the input, the +02:00 offset should not affect the output
416- Assert . Equal ( "Default Format: 09/03/2024 14:15:16 +02:00 / Custom Format String: 2024-09-03 14:15:16" , sw . ToString ( ) ) ;
420+ Assert . Equal ( """
421+ Default Format: 09/03/2024 14:15:16 +02:00
422+ Round-trip Standard Format String: 2024-09-03T14:15:16.0790000+02:00
423+ Custom Format String: 2024-09-03 14:15:16
424+ """ , sw . ToString ( ) ) ;
417425 }
418426
419427 [ Fact ]
420428 public void UtcTimestampTokenRendersUtcTime ( )
421429 {
422430 var logTimestampWithTimeZoneOffset = DateTimeOffset . Parse ( "2024-09-03T14:15:16.079+02:00" , CultureInfo . InvariantCulture ) ;
423431 var formatter = new OutputTemplateRenderer ( ConsoleTheme . None ,
424- "Default Format: {UtcTimestamp} / Custom Format String: {UtcTimestamp:yyyy-MM-dd HH:mm:ss}" ,
432+ """
433+ Default Format: {UtcTimestamp}
434+ Round-trip Standard Format String: {UtcTimestamp:o}
435+ Custom Format String: {UtcTimestamp:yyyy-MM-dd HH:mm:ss}
436+ """ ,
425437 CultureInfo . InvariantCulture ) ;
426438 var evt = new LogEvent ( logTimestampWithTimeZoneOffset , LogEventLevel . Debug , null ,
427439 new MessageTemplate ( Enumerable . Empty < MessageTemplateToken > ( ) ) , Enumerable . Empty < LogEventProperty > ( ) ) ;
428440 var sw = new StringWriter ( ) ;
429441 formatter . Format ( evt , sw ) ;
430442 // expect time in UTC, the +02:00 offset must be applied to adjust the hour
431- Assert . Equal ( "Default Format: 09/03/2024 12:15:16 / Custom Format String: 2024-09-03 12:15:16" , sw . ToString ( ) ) ;
443+ Assert . Equal ( """
444+ Default Format: 09/03/2024 12:15:16
445+ Round-trip Standard Format String: 2024-09-03T12:15:16.0790000Z
446+ Custom Format String: 2024-09-03 12:15:16
447+ """ , sw . ToString ( ) ) ;
432448 }
433449}
0 commit comments