@calipsa/tz-utils
v2.1.0
Published
JavaScript timezone utils
Downloads
257
Readme
@calipsa/tz-utils
Installation
# using npm:
npm install --save @calipsa/tz-utils
# or if you like yarn:
yarn add @calipsa/tz-utils
Available Methods
import {
formatDateTz,
} from '@calipsa/tz-utils'
const date = new Date('2021-10-10T03:00:00.005Z')
const dateInNYTz = formatDateTz(date, 'yyyy-MM-dd hh:mm:ss', 'America/New_York')
import {
names,
} from '@calipsa/tz-utils'
// names is an array containing all timezones as string values
import {
deprecatedNames,
} from '@calipsa/tz-utils'
// deprecatedNames is an array containing all deprecated timezones as string values
import {
notWorkingInDateFns,
} from '@calipsa/tz-utils'
// notWorkingInDateFns is an array containing all non-compatible timezones as string values
import {
offset,
} from '@calipsa/tz-utils'
const offsetNYC = offset('America/New_York') // will return -240 (GMT-4)
const offsetKolkata = offset('Asia/Kolkata') // will return 330 (GMT+5:30)
import {
offsetFormattedShort,
} from '@calipsa/tz-utils'
const offsetNYC = offset('America/New_York') // will return GMT-4
const offsetKolkata = offset('Asia/Kolkata') // will return GMT+5:30
import {
offsetFormattedLong,
} from '@calipsa/tz-utils'
const offsetNYC = offset('America/New_York') // will return GMT-04:00
const offsetKolkata = offset('Asia/Kolkata') // will return GMT+05:30
import {
suggested,
} from '@calipsa/tz-utils'
const timezone = suggested()
Usage
import {
formatDateTz,
names,
offset,
offsetFormattedLong,
offsetFormattedShort,
suggested,
} from '@calipsa/tz-utils'
// ...