added gradha's improvements for the times module (issue #231)

This commit is contained in:
Araq
2013-02-22 00:48:09 +01:00
parent 45c9975e9c
commit 3c8a80eeb2

View File

@@ -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.