bug fix: + and - handle GM and Local time correctly
eg, getGmTime(getTime()) + initInterval(hours=1) gave incorrect results
This commit is contained in:
parent
612cd2161a
commit
c122d71e66
1 changed files with 8 additions and 8 deletions
|
|
@ -307,9 +307,9 @@ proc `+`*(a: TimeInfo, interval: TimeInterval): TimeInfo =
|
||||||
## very accurate.
|
## very accurate.
|
||||||
let t = toSeconds(timeInfoToTime(a))
|
let t = toSeconds(timeInfoToTime(a))
|
||||||
let secs = toSeconds(a, interval)
|
let secs = toSeconds(a, interval)
|
||||||
if a.tzname == "UTC":
|
#if a.tzname == "UTC":
|
||||||
result = getGMTime(fromSeconds(t + secs))
|
# result = getGMTime(fromSeconds(t + secs))
|
||||||
else:
|
#else:
|
||||||
result = getLocalTime(fromSeconds(t + secs))
|
result = getLocalTime(fromSeconds(t + secs))
|
||||||
|
|
||||||
proc `-`*(a: TimeInfo, interval: TimeInterval): TimeInfo =
|
proc `-`*(a: TimeInfo, interval: TimeInterval): TimeInfo =
|
||||||
|
|
@ -319,9 +319,9 @@ proc `-`*(a: TimeInfo, interval: TimeInterval): TimeInfo =
|
||||||
## when you subtract so much that you reach the Julian calendar.
|
## when you subtract so much that you reach the Julian calendar.
|
||||||
let t = toSeconds(timeInfoToTime(a))
|
let t = toSeconds(timeInfoToTime(a))
|
||||||
let secs = toSeconds(a, interval)
|
let secs = toSeconds(a, interval)
|
||||||
if a.tzname == "UTC":
|
#if a.tzname == "UTC":
|
||||||
result = getGMTime(fromSeconds(t - secs))
|
# result = getGMTime(fromSeconds(t - secs))
|
||||||
else:
|
#else:
|
||||||
result = getLocalTime(fromSeconds(t - secs))
|
result = getLocalTime(fromSeconds(t - secs))
|
||||||
|
|
||||||
when not defined(JS):
|
when not defined(JS):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue