diff options
author | data-man <datamanrb@gmail.com> | 2018-04-01 00:41:38 +0300 |
---|---|---|
committer | data-man <datamanrb@gmail.com> | 2018-04-01 00:41:38 +0300 |
commit | 759023e157806bf9cdeb9f442002367a55fb8698 (patch) | |
tree | 371e7fde17def8a852b5c75e4ba7860581635a99 /lib/pure/times.nim | |
parent | 455dd3613559ef43fc7609580d7658ceaa7a36fe (diff) | |
download | Nim-759023e157806bf9cdeb9f442002367a55fb8698.tar.gz |
Comparing datetimes
Diffstat (limited to 'lib/pure/times.nim')
-rw-r--r-- | lib/pure/times.nim | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/pure/times.nim b/lib/pure/times.nim index 6c1e1fe87..75b5bac43 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -274,6 +274,18 @@ proc toTime*(dt: DateTime): Time {.tags: [], raises: [], benign.} = # so we need to compensate for that here. result.inc dt.utcOffset +proc `<`*(a, b: DateTime): bool = + ## Returns true iff ``a < b``, that is iff a happened before b. + return a.toTime < b.toTime + +proc `<=` * (a, b: DateTime): bool = + ## Returns true iff ``a <= b``. + return a.toTime <= b.toTime + +proc `==`*(a, b: DateTime): bool = + ## Returns true if ``a == b``, that is if both dates represent the same point in datetime. + return a.toTime == b.toTime + proc initDateTime(zt: ZonedTime, zone: Timezone): DateTime = let adjTime = zt.adjTime.int64 let epochday = (if adjTime >= 0: adjTime else: adjTime - (secondsInDay - 1)) div secondsInDay |