chrono

Calendars, Timestamps and Timezones utilities.

Readme

Chrono a Timestamps, Calendars, and Timezones library for nim.

Documentation: https://treeform.github.io/chrono/

Works in c as well as in javascript! All calendar manipulations! Include only the timezones and years you need!

Parse Timestamps

var ts = parseTs(
  "{year/4}-{month/2}-{day/2}T{hour/2}:{minute/2}:{second/2}Z",
  "1988-02-09T03:34:12Z"
)

Format Timestamps

echo formatTs(
  ts,
  "{year/4}-{month/2}-{day/2}T{hour/2}:{minute/2}:{second/2}Z",
)

Manipulate Calendars

var cal = Calendar(year: 2013, month: 12, day: 31, hour: 59, minute: 59, second: 59)
cal.add(Second, 20)
cal.sub(Minute, 15)
cal.add(Day, 40)
cal.sub(Month, 120)
cal.toStartOf(Day)
cal.toEndOf(Month)

Use Timezones

echo formatTs(
    ts,
    "{year/4}-{month/2}-{day/2}T{hour/2}:{minute/2}:{second/2}Z",
    tzName = "America/Los_Angeles"
)

Include only the timezones and years you need:

# The year range you want to include
const startYear = 1970
const endYear = 2030
# Add only time zones you want to include here:
const includeOnly: seq[string] = @[
  "utc",
  "America/Los_Angeles",
  "America/New_York"
]

Then just run nimble generate

More: https://treeform.github.io/chrono/

Need help? Read Nimble
Author:
treeform
No tagged versions available
License: MIT

Project website Docs Hosted docs