bug fix: + and - handle GM and Local time correctly

eg,  getGmTime(getTime()) + initInterval(hours=1) gave incorrect results
This commit is contained in:
JamesP
2015-09-10 17:38:00 +10:00
parent 612cd2161a
commit c122d71e66

View File

@@ -307,10 +307,10 @@ proc `+`*(a: TimeInfo, interval: TimeInterval): TimeInfo =
## very accurate.
let t = toSeconds(timeInfoToTime(a))
let secs = toSeconds(a, interval)
if a.tzname == "UTC":
result = getGMTime(fromSeconds(t + secs))
else:
result = getLocalTime(fromSeconds(t + secs))
#if a.tzname == "UTC":
# result = getGMTime(fromSeconds(t + secs))
#else:
result = getLocalTime(fromSeconds(t + secs))
proc `-`*(a: TimeInfo, interval: TimeInterval): TimeInfo =
## subtracts ``interval`` time.
@@ -319,10 +319,10 @@ proc `-`*(a: TimeInfo, interval: TimeInterval): TimeInfo =
## when you subtract so much that you reach the Julian calendar.
let t = toSeconds(timeInfoToTime(a))
let secs = toSeconds(a, interval)
if a.tzname == "UTC":
result = getGMTime(fromSeconds(t - secs))
else:
result = getLocalTime(fromSeconds(t - secs))
#if a.tzname == "UTC":
# result = getGMTime(fromSeconds(t - secs))
#else:
result = getLocalTime(fromSeconds(t - secs))
when not defined(JS):
proc epochTime*(): float {.rtl, extern: "nt$1", tags: [TimeEffect].}