All Projects → prantlf → Timezone Support

prantlf / Timezone Support

Licence: mit
Lightweight time zone support for your applications or other date libraries.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Timezone Support

Date Fns Timezone
Parsing and formatting date strings using IANA time zones for date-fns.
Stars: ✭ 118 (+31.11%)
Mutual labels:  time, date, timezone
Time
Building a better date/time library for Swift
Stars: ✭ 1,983 (+2103.33%)
Mutual labels:  time, date, timezone
Luatz
Time, Date and Timezone library for lua
Stars: ✭ 92 (+2.22%)
Mutual labels:  time, date, timezone
Js Joda
🕑 Immutable date and time library for javascript
Stars: ✭ 1,298 (+1342.22%)
Mutual labels:  time, date, timezone
TimesDates.jl
Nanosecond resolution for Time and Date, TimeZones
Stars: ✭ 28 (-68.89%)
Mutual labels:  time, date, timezone
Date
A date and time library based on the C++11/14/17 <chrono> header
Stars: ✭ 2,389 (+2554.44%)
Mutual labels:  time, date, timezone
Delorean
Delorean: Time Travel Made Easy
Stars: ✭ 1,793 (+1892.22%)
Mutual labels:  time, date, timezone
nepali-datetime
Python's core datetime inspired nepali datetime (BS date & NPT) package 🇳🇵
Stars: ✭ 36 (-60%)
Mutual labels:  time, date, timezone
time machine
A date and time API for Dart
Stars: ✭ 120 (+33.33%)
Mutual labels:  time, date, timezone
temps-lite
A smart, good-looking little app which tries to speak your language the way you are used to.
Stars: ✭ 40 (-55.56%)
Mutual labels:  time, date, timezone
hs-hourglass
efficient and simpler time API for haskell
Stars: ✭ 43 (-52.22%)
Mutual labels:  time, date, timezone
Date Fns Tz
Complementary library for date-fns v2 adding IANA time zone support
Stars: ✭ 385 (+327.78%)
Mutual labels:  time, date, timezone
Carbon
A simple PHP API extension for DateTime
Stars: ✭ 75 (-16.67%)
Mutual labels:  time, date
Moment.php
Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Stars: ✭ 900 (+900%)
Mutual labels:  time, date
Time
A simplified approach to working with dates, times, and time zones.
Stars: ✭ 83 (-7.78%)
Mutual labels:  time, timezone
Vue Datetime
Mobile friendly datetime picker for Vue. Supports date and datetime modes, i18n and more.
Stars: ✭ 928 (+931.11%)
Mutual labels:  time, date
Translatedjs
Internationalization and localization for JavaScript and Node.js
Stars: ✭ 17 (-81.11%)
Mutual labels:  time, date
Singledateandtimepicker
You can now select a date and a time with only one widget !
Stars: ✭ 921 (+923.33%)
Mutual labels:  time, date
Dayjs
⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
Stars: ✭ 37,373 (+41425.56%)
Mutual labels:  time, date
Tinydate
A tiny (349B) reusable date formatter. Extremely fast!
Stars: ✭ 990 (+1000%)
Mutual labels:  time, date

Time Zone Support

NPM version Build Status Coverage Status Codacy Badge Dependency Status devDependency Status JavaScript Style Guide

NPM Downloads

Lightweight time zone listing and date converting. Intended for adding time zone support to high-level date libraries, but also for direct application usage.

  • Tiny code base - 4.6 KB minified, 1.7 KB gzipped. Do not pack unnecessary weight in your application.
  • Packed time zone data - 924 KB minified, 33.6 KB gzipped. Single time zones are unpacked on demand.
  • Smaller bundles of code with limited data - 1900-2050 (206 kB minified, 25.4 kB gzipped), 1970-2038 (141 kB minified, 15.8 kB gzipped) and 2012-2022 (31.3 KB minified, 8.25 kB gzipped).
  • Generated from the official time zone database version 2019a. Canonical time zone names, aliases, UTC offsets, and daylight-saving time changes.
  • Minimal interface for time zone lookup and conversions. Parsing, formatting and manipulating dates is usually the task for a higher-level date library.

Attention: exported identifiers in vanilla browser modules changed in the version 2.0.0. See the migration guide for more information.

Table of Contents

Synopsis

const {
  listTimeZones, findTimeZone, getZonedTime, getUnixTime
} = require('timezone-support')

// List canonical time zone names: [ 'Africa/Abidjan', ... ]
const timeZones = listTimeZones()

// Find a particular time zone: { name: 'Europe/Berlin', ... }
const berlin = findTimeZone('Europe/Berlin')

// Convert a date to a specific time zone: { year, month, day, dayOfWeek,
// hours, minutes, seconds, milliseconds, epoch, zone: { abbreviation, offset } }
const nativeDate = new Date()
const berlinTime = getZonedTime(nativeDate, berlin)

// Convert a time from a specific time zone: native Date object
const berlinTime = { year: 2018, month: 9, day: 2, hours: 10, minutes: 0 }
const nativeDate = new Date(getUnixTime(berlinTime, berlin))

Installation and Getting Started

This module can be installed in your project using NPM or [Yarn]. Make sure, that you use Node.js version 6 or newer.

$ npm i timezone-support --save
$ yarn add timezone-support

Functions are exposed as named exports from the package modules, for example:

const { findTimeZone, getZonedTime } = require('timezone-support')

You can read more about the module loading in other environments, like with ES6 or in web browsers. Usage scenarios demonstrate applications of this library in typical real-world scenarios. Design concepts explain the approach to time zone handling taken by tni library and types of values used ion the interface. Generating custom time zone data will allow you to save the overall package size by limiting the supported year span. Finally, the API reference lists all functions with a description of their functionality.

You can see complete sample applications too, which can help you start with integration of this library.

Library Integrations

  • Day.js - timeZone plugin supplies parsing from and formatting to an arbitrary time zone
  • date-fns - date-fns-timezone provides functions for parsing from and formatting to an arbitrary time zone and time zone conversions for the native Date object.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • 2018-06-11 v2.0.2 Upgrade the time zone database to the version 2019a.
  • 2018-06-11 v2.0.1 Default to midnight, if the time part of a date is missing.
  • 2018-06-10 v2.0.0 Use proper identifiers in vanilla browser modules.
  • 2018-11-17 v1.8.0 Include time zone data for years 1970-2038.
  • 2018-11-17 v1.7.0 Include full time zone data separately loadable.
  • 2018-11-06 v1.6.0 Upgrade the time zone database to the version 2018g.
  • 2018-10-08 v1.5.5 Fix compatibility with IE. Thanks, Andrii!
  • 2018-10-06 v1.5.0 Add TypeScript export declarations.
  • 2018-09-30 v1.4.0 Add limited data for just the current decade - years 2012-2022.
  • 2018-09-18 v1.3.0 Maintain the property dayOfWeek in the time object.
  • 2018-09-16 v1.2.0 Add a new getUTCOffset method for more lightweight integrations.
  • 2018-09-03 v1.1.0 Set the property epoch to the time object.
  • 2018-09-02 v1.0.0 Initial release

License

Copyright (c) 2018-2019 Ferdinand Prantl

Licensed under the MIT license.

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].