systimes
An alternative DateTime implementation
Summary
| Latest Version | Unknown |
|---|---|
| License | MIT |
| CI Status | Passing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:24 |
Tags
Installation
nimble install systimes
choosenim install systimes
git clone https://github.com/GULPF/systimes
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| systimes | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Source
| Repository | https://github.com/GULPF/systimes |
|---|---|
| Homepage | https://github.com/GULPF/systimes |
| Registry Source | nimble_official |
README
systimes
The systimes module implements an alternative way to represent a timestamp + timezone. Nim's standard library uses the DateTime type to represent the same thing. There are two important differences between DateTime and SysTime:
SysTimeis immutable.SysTimeonly stores atimes.Timeand atimes.Timezone, meaning that individual calendar fields like year, month and so on are never stored.
Some things to keep in mind:
- When the calendar fields are accessed several times for the same object, there is a performance penalty when using
SysTimesince they must be computed at every access. - Many procs are faster for
SysTime. Notably all procs involvingDurationsince they no longer require timezone information. - Some procs are slower for
SysTime. Notably all procs involvingTimeInterval. SysTimeis much more space effecient.
The name SysTime comes from the SysTime class from Phobos, which uses a similiar representation for timestamp + timezone.
Usage
import systimes, times
let x = sysnow()
let y = initSysTime(01, mJan, 2000, 12, 00, 00, utc())
doAssert x > y
doAssert x < y + 10.years
echo y # 2000-01-01T12:00:00Z
systimes exposes a very similiar API for SysTime as the times module does for DateTime. Notable differences are listed in the table below. Generated docs are available here.
| DateTime | SysTime |
|---|---|
now() |
sysnow() |
parse(input, format) |
parseSysTime(input, format) |
time.inZone(zone) |
initSysTime(time, zone) |
initDateTime(...) |
initSysTime(...) |