All Projects → GULPF → timezones

GULPF / timezones

Licence: MIT license
Nim timezone library compatible with the standard library.

Programming Languages

nim
578 projects

Projects that are alternatives of or similar to timezones

Ticktock
A timezone data management library for the JVM and Android targeting java.time APIs in Java 8+
Stars: ✭ 122 (+229.73%)
Mutual labels:  time, timezone
Date
A date and time library based on the C++11/14/17 <chrono> header
Stars: ✭ 2,389 (+6356.76%)
Mutual labels:  time, timezone
Tzupdate
Set the system timezone based on IP geolocation
Stars: ✭ 130 (+251.35%)
Mutual labels:  time, timezone
Js Joda
🕑 Immutable date and time library for javascript
Stars: ✭ 1,298 (+3408.11%)
Mutual labels:  time, timezone
temps-lite
A smart, good-looking little app which tries to speak your language the way you are used to.
Stars: ✭ 40 (+8.11%)
Mutual labels:  time, timezone
Luatz
Time, Date and Timezone library for lua
Stars: ✭ 92 (+148.65%)
Mutual labels:  time, timezone
Time
Building a better date/time library for Swift
Stars: ✭ 1,983 (+5259.46%)
Mutual labels:  time, timezone
Date Fns Tz
Complementary library for date-fns v2 adding IANA time zone support
Stars: ✭ 385 (+940.54%)
Mutual labels:  time, timezone
Friend-Time
Discord bot - Friend Time helps your server coordinate times and events by converting times mentioned in chat between time zones!
Stars: ✭ 62 (+67.57%)
Mutual labels:  time, timezone
Prayer Times Android Azan
Prayer + Time + Android + Kotlin + Azan + Library + timezone + islamic + salah + Library aiming to calculate prayer time with one line code , if you implement prayer time application , there is no need to do this headache again .
Stars: ✭ 251 (+578.38%)
Mutual labels:  time, timezone
Timezone Support
Lightweight time zone support for your applications or other date libraries.
Stars: ✭ 90 (+143.24%)
Mutual labels:  time, timezone
TimesDates.jl
Nanosecond resolution for Time and Date, TimeZones
Stars: ✭ 28 (-24.32%)
Mutual labels:  time, timezone
Time
A simplified approach to working with dates, times, and time zones.
Stars: ✭ 83 (+124.32%)
Mutual labels:  time, timezone
Date Fns Timezone
Parsing and formatting date strings using IANA time zones for date-fns.
Stars: ✭ 118 (+218.92%)
Mutual labels:  time, timezone
Posix tz db
Generates POSIX timezones strings
Stars: ✭ 57 (+54.05%)
Mutual labels:  time, timezone
Delorean
Delorean: Time Travel Made Easy
Stars: ✭ 1,793 (+4745.95%)
Mutual labels:  time, timezone
nepali-datetime
Python's core datetime inspired nepali datetime (BS date & NPT) package 🇳🇵
Stars: ✭ 36 (-2.7%)
Mutual labels:  time, timezone
NTP
NTP library for Arduino framework
Stars: ✭ 20 (-45.95%)
Mutual labels:  time, timezone
Timezone
Arduino library to facilitate time zone conversions and automatic daylight saving (summer) time adjustments.
Stars: ✭ 205 (+454.05%)
Mutual labels:  time, timezone
time machine
A date and time API for Dart
Stars: ✭ 120 (+224.32%)
Mutual labels:  time, timezone

Timezones CI

A Nim library for working with timezones. It uses the IANA timezone database as a source for the timezone definitions. Both the C based backends and the JS backend are supported.

Installation

Timezones is available on Nimble:

nimble install timezones

Usage

import times
import timezones

# Create a timezone representing a static offset from UTC.
let zone = tz"+02:30"
echo initDateTime(1, mJan, 2000, 12, 00, 00, zone)
# => 2000-01-01T12:00:00+02:30

# Static offset timezones can also be created with the proc ``staticTz``,
# which is preferable if the offset is only known at runtime.
doAssert zone == staticTz(hours = -2, minutes = -30)

# Create a timezone representing a timezone in the IANA timezone database.
let stockholm = tz"Europe/Stockholm"
echo initDateTime(1, mJan, 1850, 00, 00, 00, stockholm)
# => 1850-01-01T00:00:00+01:12

# Like above, but returns a `TimezoneInfo` object which contains some
# extra metadata.
let stockholmInfo = tzInfo"Europe/Stockholm"
# Countries are specified with it's two character country code,
# see ISO 3166-1 alpha-2.
doAssert stockholmInfo.countries == @["SE"]
doAssert stockholmInfo.timezone == stockholm

# Note that some timezones are used by multiple countries.
let bangkok = tzInfo"Asia/Bangkok"
doAssert bangkok.countries == @["TH", "KH", "LA", "VN"]

API

Advanced usage

The timezone definitions from a IANA timezone database release are stored in a JSON file. This repo includes the currently latest release, but no guarantee is given as to how fast the bundled timezone database is updated when IANA releases a new version. The JSON file can either be embeeded into the executable (which is the default behavior), or be loaded at runtime.

If you want control over when the timezone definitions are updated, there are two options:

  • Embeed a custom JSON file
  • Load a JSON file at runtime

Both options require you to generate the JSON file yourself. See fetchjsontimezones for information on how to accomplish that.

To embeed a custom JSON file, simply pass -d:timezonesPath={path}>, where {path} is the absolute path to the file.

To load a JSON definition at runtime, either of these procs can be used:

proc parseJsonTimezones*(content: string): TzData
proc loadJsonTimezones*(path: string): TzData # Not available for the JS backend

If you load the JSON timezones at runtime, it's likely that you don't need the bundled definitions. To disable the embeededing of the bundled JSON file, -d:timezonesNoEmbeed can be passed.

fetchjsontimezones

NOTE: The fetchjsontimezones tool isn't supported on Windows for now.

fetchjsontimezones is a command line tool for downloading IANA timezone database releases and converting them to the JSON format used by the timezones module. It's part of this repo and is installed by running nimble install timezones. Using fetchjsontimezones isn't required for using the timezones module, but it's needed to load timezone data during runtime.

Usage (fetchjsontimezones --help):

   fetchjsontimezones <version> # Download <version>, e.g '2018d'.

   --help                       # Print this help message
   --out:<file>, -o:<file>      # Write output to this file.
                                # Defaults to './<version>.json'.
   --timezones:<zones>          # Only store transitions for these timezones.
   --regions:<regions>          # Only store transitions for these regions.

For example, fetchjsontimezones 2020d --out:tzdata.json --regions:"europe northamerica" will create a timezone data file called tzdata.json containing timzeone transitions for the regions 'europe' and 'northamerica' generated from the 2020d timezone database release.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].