diff --git a/vlib/time/format.v b/vlib/time/format.v index bff6fa83e7..5a6c0d5b7c 100644 --- a/vlib/time/format.v +++ b/vlib/time/format.v @@ -24,7 +24,8 @@ pub fn (t Time) format_ss_milli() string { // RFC3339 is an Internet profile, based on the ISO 8601 standard for for representation of dates and times using the Gregorian calendar. // It is intended to improve consistency and interoperability, when representing and using date and time in Internet protocols. pub fn (t Time) format_rfc3339() string { - return '${t.year:04d}-${t.month:02d}-${t.day:02d}T${t.hour:02d}:${t.minute:02d}:${t.second:02d}.${(t.microsecond / 1000):03d}Z' + u := t.add(-offset() * second) + return '${u.year:04d}-${u.month:02d}-${u.day:02d}T${u.hour:02d}:${u.minute:02d}:${u.second:02d}.${(u.microsecond / 1000):03d}Z' } // format_ss_micro returns a date string in "YYYY-MM-DD HH:mm:ss.123456" format (24h). diff --git a/vlib/time/time_test.v b/vlib/time/time_test.v index 2772aeb78f..48ec08cf40 100644 --- a/vlib/time/time_test.v +++ b/vlib/time/time_test.v @@ -94,7 +94,11 @@ fn test_format_ss_milli() { } fn test_format_rfc3339() { - assert '1980-07-11T21:23:42.123Z' == time_to_test.format_rfc3339() + // assert '1980-07-11T19:23:42.123Z' + res := time_to_test.format_rfc3339() + assert res.ends_with('23:42.123Z') + assert res.starts_with('1980-07-1') + assert res.contains('T') } fn test_format_ss_micro() {