diff options
author | Araq <rumpf_a@web.de> | 2013-02-22 00:48:09 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-02-22 00:48:09 +0100 |
commit | 3c8a80eeb2fd09481315514fda7ba85f417ac13d (patch) | |
tree | 18dcf009718dcb9e5c5b2f8018bd30d612d58bca | |
parent | 45c9975e9c9fe063d68aa5eb6df0457ca9ac7457 (diff) | |
download | Nim-3c8a80eeb2fd09481315514fda7ba85f417ac13d.tar.gz |
added gradha's improvements for the times module (issue #231)
-rwxr-xr-x | lib/pure/times.nim | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/pure/times.nim b/lib/pure/times.nim index 6a73303d9..b86c72ed3 100755 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -33,6 +33,7 @@ when defined(posix): type TTimeImpl {.importc: "time_t", header: "<sys/time.h>".} = int TTime* = distinct TTimeImpl ## distinct type that represents a time + ## measured as number of seconds since the epoch Ttimeval {.importc: "struct timeval", header: "<sys/select.h>", final, pure.} = object ## struct timeval @@ -132,7 +133,10 @@ type months*: int ## The number of months years*: int ## The number of years -proc getTime*(): TTime {.tags: [FTime].} ## gets the current calendar time +proc getTime*(): TTime {.tags: [FTime].} + ## gets the current calendar time as a UNIX epoch value (number of seconds + ## elapsed since 1970) with integer precission. Use epochTime for higher + ## resolution. proc getLocalTime*(t: TTime): TTimeInfo ## converts the calendar time `t` to broken-time representation, ## expressed relative to the user's specified time zone. @@ -165,6 +169,10 @@ proc `<=` * (a, b: TTime): bool {. ## returns true iff ``a <= b``. result = a - b <= 0 +proc `==`*(a, b: TTime): bool {.rtl, extern: "ntEqTime".} = + ## returns true if ``a == b``, that is if both times represent the same value + result = a - b == 0 + proc getTzname*(): tuple[nonDST, DST: string] {.tags: [FTime].} ## returns the local timezone; ``nonDST`` is the name of the local non-DST ## timezone, ``DST`` is the name of the local DST timezone. |