Skip to content

Commit

Permalink
fix: time on 32 bits architecture (#2492)
Browse files Browse the repository at this point in the history
authored-by: Emil Ivanichkov <emil.ivanichkov@gmail.com>
  • Loading branch information
SionoiS authored Mar 1, 2024
1 parent 560f949 commit 0a75122
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/testlib/wakucore.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions tests/waku_core/test_time.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions waku/waku_core/time.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 0a75122

Please sign in to comment.