mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
Fixed TimeInterval bug.
This commit is contained in:
@@ -171,11 +171,6 @@ type
|
||||
{.deprecated: [TMonth: Month, TWeekDay: WeekDay, TTime: Time,
|
||||
TTimeInterval: TimeInterval, TTimeInfo: TimeInfo].}
|
||||
|
||||
proc miliseconds*(t: TimeInterval): int {.deprecated.} = t.milliseconds
|
||||
|
||||
proc `miliseconds=`*(t:var TimeInterval, milliseconds: int) {.deprecated.} =
|
||||
t.milliseconds = milliseconds
|
||||
|
||||
proc getTime*(): Time {.tags: [TimeEffect], benign.}
|
||||
## gets the current calendar time as a UNIX epoch value (number of seconds
|
||||
## elapsed since 1970) with integer precission. Use epochTime for higher
|
||||
@@ -351,7 +346,6 @@ proc toSeconds(a: TimeInfo, interval: TimeInterval): float =
|
||||
else:
|
||||
curMonth.inc()
|
||||
result += float(newinterv.days * 24 * 60 * 60)
|
||||
result += float(newinterv.days * 24 * 60 * 60)
|
||||
result += float(newinterv.hours * 60 * 60)
|
||||
result += float(newinterv.minutes * 60)
|
||||
result += float(newinterv.seconds)
|
||||
@@ -383,6 +377,15 @@ proc `-`*(a: TimeInfo, interval: TimeInterval): TimeInfo =
|
||||
let secs = toSeconds(a, intval)
|
||||
result = getLocalTime(fromSeconds(t + secs))
|
||||
|
||||
proc miliseconds*(t: TimeInterval): int {.deprecated.} = t.milliseconds
|
||||
|
||||
proc `miliseconds=`*(t: var TimeInterval, milliseconds: int) {.deprecated.} =
|
||||
## An alias for a misspelled field in ``TimeInterval``.
|
||||
##
|
||||
## **Warning:** This should not be used! It will be removed in the next
|
||||
## version.
|
||||
t.milliseconds = milliseconds
|
||||
|
||||
when not defined(JS):
|
||||
proc epochTime*(): float {.rtl, extern: "nt$1", tags: [TimeEffect].}
|
||||
## gets time after the UNIX epoch (1970) in seconds. It is a float
|
||||
|
||||
@@ -142,3 +142,8 @@ doAssert initInterval(milliseconds = 25000) == initInterval(seconds = 25)
|
||||
doAssert initInterval(seconds = 65) == initInterval(seconds = 5, minutes = 1)
|
||||
doAssert initInterval(hours = 25) == initInterval(hours = 1, days = 1)
|
||||
doAssert initInterval(months = 13) == initInterval(months = 1, years = 1)
|
||||
|
||||
# Bug with adding a day to a Time
|
||||
let day = 24.hours
|
||||
let tomorrow = getTime() + day
|
||||
doAssert tomorrow - getTime() == 60*60*24
|
||||
Reference in New Issue
Block a user