times - remove unneeded negative sign when parsing formats z and zz (#9631)
* fix wrong utcoffset sign for formats z and zz * add tests for the timezone offset formats
This commit is contained in:
parent
73c306258b
commit
b9cdad7497
2 changed files with 12 additions and 3 deletions
|
|
@ -2026,9 +2026,9 @@ proc parsePattern(input: string, pattern: FormatPattern, i: var int,
|
||||||
var offset = 0
|
var offset = 0
|
||||||
case pattern
|
case pattern
|
||||||
of z:
|
of z:
|
||||||
offset = takeInt(1..2) * -3600
|
offset = takeInt(1..2) * 3600
|
||||||
of zz:
|
of zz:
|
||||||
offset = takeInt(2..2) * -3600
|
offset = takeInt(2..2) * 3600
|
||||||
of zzz:
|
of zzz:
|
||||||
offset.inc takeInt(2..2) * 3600
|
offset.inc takeInt(2..2) * 3600
|
||||||
if input[i] != ':':
|
if input[i] != ':':
|
||||||
|
|
@ -2508,4 +2508,4 @@ proc zoneInfoFromUtc*(zone: Timezone, time: Time): ZonedTime
|
||||||
proc zoneInfoFromTz*(zone: Timezone, adjTime: Time): ZonedTime
|
proc zoneInfoFromTz*(zone: Timezone, adjTime: Time): ZonedTime
|
||||||
{.deprecated: "Use zonedTimeFromAdjTime instead".} =
|
{.deprecated: "Use zonedTimeFromAdjTime instead".} =
|
||||||
## **Deprecated since v0.19.0:** use the ``zonedTimeFromAdjTime`` instead.
|
## **Deprecated since v0.19.0:** use the ``zonedTimeFromAdjTime`` instead.
|
||||||
zone.zonedTimeFromAdjTime(adjTime)
|
zone.zonedTimeFromAdjTime(adjTime)
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,15 @@ template runTimezoneTests() =
|
||||||
# formatting timezone as 'Z' for UTC
|
# formatting timezone as 'Z' for UTC
|
||||||
parseTest("2001-01-12T22:04:05Z", "yyyy-MM-dd'T'HH:mm:ss" & tzFormat,
|
parseTest("2001-01-12T22:04:05Z", "yyyy-MM-dd'T'HH:mm:ss" & tzFormat,
|
||||||
"2001-01-12T22:04:05Z", 11)
|
"2001-01-12T22:04:05Z", 11)
|
||||||
|
# timezone offset formats
|
||||||
|
parseTest("2001-01-12T15:04:05 +7", "yyyy-MM-dd'T'HH:mm:ss z",
|
||||||
|
"2001-01-12T08:04:05Z", 11)
|
||||||
|
parseTest("2001-01-12T15:04:05 +07", "yyyy-MM-dd'T'HH:mm:ss zz",
|
||||||
|
"2001-01-12T08:04:05Z", 11)
|
||||||
|
parseTest("2001-01-12T15:04:05 +07:00", "yyyy-MM-dd'T'HH:mm:ss zzz",
|
||||||
|
"2001-01-12T08:04:05Z", 11)
|
||||||
|
parseTest("2001-01-12T15:04:05 +07:30:59", "yyyy-MM-dd'T'HH:mm:ss zzzz",
|
||||||
|
"2001-01-12T07:33:06Z", 11)
|
||||||
# Kitchen = "3:04PM"
|
# Kitchen = "3:04PM"
|
||||||
parseTestTimeOnly("3:04PM", "h:mmtt", "15:04:00")
|
parseTestTimeOnly("3:04PM", "h:mmtt", "15:04:00")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue