added gradha's improvements for the times module (issue #231)
This commit is contained in:
parent
45c9975e9c
commit
3c8a80eeb2
1 changed files with 9 additions and 1 deletions
|
|
@ -33,6 +33,7 @@ when defined(posix):
|
||||||
type
|
type
|
||||||
TTimeImpl {.importc: "time_t", header: "<sys/time.h>".} = int
|
TTimeImpl {.importc: "time_t", header: "<sys/time.h>".} = int
|
||||||
TTime* = distinct TTimeImpl ## distinct type that represents a time
|
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>",
|
Ttimeval {.importc: "struct timeval", header: "<sys/select.h>",
|
||||||
final, pure.} = object ## struct timeval
|
final, pure.} = object ## struct timeval
|
||||||
|
|
@ -132,7 +133,10 @@ type
|
||||||
months*: int ## The number of months
|
months*: int ## The number of months
|
||||||
years*: int ## The number of years
|
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
|
proc getLocalTime*(t: TTime): TTimeInfo
|
||||||
## converts the calendar time `t` to broken-time representation,
|
## converts the calendar time `t` to broken-time representation,
|
||||||
## expressed relative to the user's specified time zone.
|
## expressed relative to the user's specified time zone.
|
||||||
|
|
@ -165,6 +169,10 @@ proc `<=` * (a, b: TTime): bool {.
|
||||||
## returns true iff ``a <= b``.
|
## returns true iff ``a <= b``.
|
||||||
result = a - b <= 0
|
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].}
|
proc getTzname*(): tuple[nonDST, DST: string] {.tags: [FTime].}
|
||||||
## returns the local timezone; ``nonDST`` is the name of the local non-DST
|
## returns the local timezone; ``nonDST`` is the name of the local non-DST
|
||||||
## timezone, ``DST`` is the name of the local DST timezone.
|
## timezone, ``DST`` is the name of the local DST timezone.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue