mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 17:34:43 +00:00
added gradha's improvements for the times module (issue #231)
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user