Module systimes

Types

SysTime = object
  time: Time
  timezone: Timezone
Represents a point-in-time with an attached timezone.

Procs

proc timezone(stime: SysTime): Timezone {...}{.raises: [], tags: [].}
Returns the attached timezone.
proc initSysTime(time: Time; zone: Timezone): SysTime {...}{.raises: [], tags: [].}
proc initSysTime(monthday: MonthdayRange; month: Month; year: int; hour: HourRange;
                minute: MinuteRange; second: SecondRange;
                nanosecond: NanosecondRange; zone = local()): SysTime {...}{.raises: [],
    tags: [].}
proc initSysTime(monthday: MonthdayRange; month: Month; year: int; hour: HourRange;
                minute: MinuteRange; second: SecondRange; zone = local()): SysTime {...}{.
    raises: [], tags: [].}
proc inZone(stime: SysTime; zone: Timezone): SysTime {...}{.raises: [], tags: [].}
Swap timezone to zone.
proc toTime(stime: SysTime): Time {...}{.raises: [], tags: [].}

Convert SysTime to Time.

Note that unlike times.DateTime, SysTime is represented internally as a Time so this proc is just a field access.

proc toDateTime(stime: SysTime): DateTime {...}{.raises: [], tags: [].}
Convert a SysTime to a times.DateTime.
proc toSysTime(dt: DateTime): SysTime {...}{.raises: [], tags: [].}
Convert a times.DateTime to a SysTime.
proc sysnow(): SysTime {...}{.raises: [], tags: [TimeEffect].}
Get the current time as a SysTime.
proc local(stime: SysTime): SysTime {...}{.raises: [], tags: [].}
Shorthand for stime.inZone(local())
proc utc(stime: SysTime): SysTime {...}{.raises: [], tags: [].}
Shorthand for stime.inZone(utc())
proc isDst(stime: SysTime): bool {...}{.raises: [], tags: [].}
Returns true if stime observes DST, and false if not.
proc utcOffset(stime: SysTime): int {...}{.raises: [], tags: [].}
Returns the timezone offset in seconds west of UTC.
proc year(stime: SysTime): int {...}{.raises: [], tags: [].}
proc month(stime: SysTime): Month {...}{.raises: [], tags: [].}
proc monthday(stime: SysTime): MonthdayRange {...}{.raises: [], tags: [].}
proc hour(stime: SysTime): HourRange {...}{.raises: [], tags: [].}
Returns the hour of the day in the range 0 .. 23.
proc minute(stime: SysTime): MinuteRange {...}{.raises: [], tags: [].}
Returns the minute of the hour in the range 0 .. 59
proc second(stime: SysTime): SecondRange {...}{.raises: [], tags: [].}

Returns the second of the minute in the range 0 .. 59.

Note that the SecondRange type allows the range 0 .. 60 because of leap seconds, but a leap second will never be returned by this proc.

proc nanosecond(stime: SysTime): NanosecondRange {...}{.raises: [], tags: [].}
Returns the nanosecond of the second in the range 0 .. 999_999_999.
proc yearday(stime: SysTime): YeardayRange {...}{.raises: [], tags: [].}
Returns the day of the year in the range 0 .. 365.
proc weekday(stime: SysTime): WeekDay {...}{.raises: [], tags: [].}
Returns the day of the week as an enum.
proc `<`(a, b: SysTime): bool {...}{.raises: [], tags: [].}
proc `<=`(a, b: SysTime): bool {...}{.raises: [], tags: [].}
proc `==`(a, b: SysTime): bool {...}{.raises: [], tags: [].}
Returns true if a and b represent the same point in time. Note that the timezone doesn't need to match!

Examples:

import
  times

let a = sysnow()
let b = a.inZone(utc())
doAssert a == a
doAssert a == b
proc `-`(a, b: SysTime): Duration {...}{.raises: [], tags: [].}
proc `+`(stime: SysTime; dur: Duration): SysTime {...}{.raises: [], tags: [].}
proc `-`(stime: SysTime; dur: Duration): SysTime {...}{.raises: [], tags: [].}
proc `+`(stime: SysTime; interval: TimeInterval): SysTime {...}{.raises: [], tags: [].}
proc `-`(stime: SysTime; interval: TimeInterval): SysTime {...}{.raises: [], tags: [].}
proc between(low, high: SysTime): TimeInterval {...}{.raises: [], tags: [].}
proc parseSysTime(input, f: string; zone: Timezone): SysTime {...}{.
    raises: [ValueError, OverflowError, UnpackError], tags: [TimeEffect].}
proc parseSysTime(input, f: static[string]; zone: Timezone): SysTime
proc format(stime: SysTime; f: TimeFormat): string {...}{.raises: [], tags: [].}
proc format(stime: SysTime; f: string): string {...}{.raises: [ValueError], tags: [].}
proc format(stime: SysTime; f: static[string]): string
proc `$`(stime: SysTime): string {...}{.raises: [], tags: [].}
Stringification of a SysTime. Uses the same format as times.$ for times.DateTime.