1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

time: use UTC time in Time.format_rfc3339, make test more robust

This commit is contained in:
Delyan Angelov
2022-12-11 10:36:29 +02:00
parent 2ecb892985
commit 94098eef79
2 changed files with 7 additions and 2 deletions

View File

@@ -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).