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

time: add more UTC/local time conversion functions, make Time.format_rfc3339 more stable

This commit is contained in:
Delyan Angelov
2022-12-11 13:32:40 +02:00
parent 73e886eafe
commit ad24c22250
3 changed files with 97 additions and 1 deletions

View File

@ -24,7 +24,7 @@ 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 {
u := t.add(-offset() * second)
u := t.local_to_utc()
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'
}