mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-08 17:03:09 +00:00
fix: time on 32 bits architecture (#2492)
authored-by: Emil Ivanichkov <emil.ivanichkov@gmail.com>
This commit is contained in:
parent
75521122a4
commit
4638756aef
@ -20,7 +20,7 @@ proc now*(): Timestamp =
|
||||
getNanosecondTime(getTime().toUnixFloat())
|
||||
|
||||
proc ts*(offset=0, origin=now()): Timestamp =
|
||||
origin + getNanosecondTime(offset)
|
||||
origin + getNanosecondTime(int64(offset))
|
||||
|
||||
|
||||
# Switch
|
||||
|
||||
@ -21,14 +21,10 @@ suite "Waku Core - Time":
|
||||
|
||||
## When
|
||||
let
|
||||
timeInSecondsInt = secondsPart.int
|
||||
timeInSecondsInt64 = secondsPart.int64
|
||||
timeInSecondsFloat = float(secondsFloat)
|
||||
timeInSecondsFloat64 = float64(secondsFloat)
|
||||
|
||||
## Then
|
||||
check:
|
||||
getNanosecondTime(timeInSecondsInt) == lowResTimestamp
|
||||
getNanosecondTime(timeInSecondsInt64) == lowResTimestamp
|
||||
getNanosecondTime(timeInSecondsFloat) == highResTimestamp
|
||||
getNanosecondTime(timeInSecondsFloat64) == highResTimestamp
|
||||
|
||||
@ -9,8 +9,8 @@ import
|
||||
|
||||
type Timestamp* = int64 # A nanosecond precision timestamp
|
||||
|
||||
proc getNanosecondTime*[T: SomeNumber](timeInSeconds: T): Timestamp =
|
||||
var ns = Timestamp(timeInSeconds * 1_000_000_000.T)
|
||||
proc getNanosecondTime*(timeInSeconds: int64 | float64): Timestamp =
|
||||
let ns = Timestamp(timeInSeconds * 1_000_000_000)
|
||||
return ns
|
||||
|
||||
proc nowInUnixFloat(): float =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user