mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-01-16 01:34:12 +00:00
18 lines
438 B
Nim
18 lines
438 B
Nim
import pkg/stint
|
|
|
|
type
|
|
Periodicity* = object
|
|
seconds*: UInt256
|
|
|
|
Period* = UInt256
|
|
Timestamp* = UInt256
|
|
|
|
func periodOf*(periodicity: Periodicity, timestamp: Timestamp): Period =
|
|
timestamp div periodicity.seconds
|
|
|
|
func periodStart*(periodicity: Periodicity, period: Period): Timestamp =
|
|
period * periodicity.seconds
|
|
|
|
func periodEnd*(periodicity: Periodicity, period: Period): Timestamp =
|
|
periodicity.periodStart(period + 1)
|