Fix times.+ and - for TimeInfo and TimeInterval.
This commit is contained in:
parent
f5bdc138bb
commit
8182414a6f
1 changed files with 9 additions and 3 deletions
|
|
@ -369,7 +369,10 @@ proc `+`*(a: TimeInfo, interval: TimeInterval): TimeInfo =
|
|||
## very accurate.
|
||||
let t = toSeconds(toTime(a))
|
||||
let secs = toSeconds(a, interval)
|
||||
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 from TimeInfo ``a``.
|
||||
|
|
@ -386,7 +389,10 @@ proc `-`*(a: TimeInfo, interval: TimeInterval): TimeInfo =
|
|||
intval.months = - interval.months
|
||||
intval.years = - interval.years
|
||||
let secs = toSeconds(a, intval)
|
||||
result = getLocalTime(fromSeconds(t + secs))
|
||||
if a.tzname == "UTC":
|
||||
result = getGMTime(fromSeconds(t + secs))
|
||||
else:
|
||||
result = getLocalTime(fromSeconds(t + secs))
|
||||
|
||||
proc miliseconds*(t: TimeInterval): int {.deprecated.} = t.milliseconds
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue