Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #3 Add CommonJS and Typescript compatibility #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions esm/esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @fileoverview
*
* This package contains an array of timezones based on conventional options found online.
* It does not follow any complete data set, but all names are according to the tz format:
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
*
* More specifically, the fields in the array are:
* – offset, a string from '-11:00' to '+14:00' representing the UTC offset
* - label, a readable label that contains the offset and a longer, descriptive name of the timezone
* - tzCode, the value from the tz standard
*
* Install:
* `npm install compact-timezone-list --save`
* # or
* `yarn add compact-timezone-list`
*
*
* Example:
* import timezones from 'compact-timezone-list';
* // or
* import { minimalTimezoneSet } from 'compact-timezone-list';
*
* Details:
* - The default export provides a long list of options, with multiple
* suggestions for each UTC offset.
* – The `minimalTimezoneSet` export provides one option per offset type, with
* a favourite chosen to represent each offset. This is mostly targeted to small,
* western-focused apps. But, every UTC offset is included.
*/

import cjsModule from '../index.js';

export default cjsModule.defaultTimezoneSet;
export var defaultTimezoneSet = cjsModule.defaultTimezoneSet;
export var minimalTimezoneSet = cjsModule.minimalTimezoneSet;
36 changes: 36 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @fileoverview
*
* This package contains an array of timezones based on conventional options found online.
* It does not follow any complete data set, but all names are according to the tz format:
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
*
* Install:
* `npm install compact-timezone-list --save`
* # or
* `yarn add compact-timezone-list`
*
*
* Example:
* import { defaultTimezoneSet } from 'compact-timezone-list';
* // or
* import { minimalTimezoneSet } from 'compact-timezone-list';
*
* Details:
* - The 'defaultTimezoneSet' export provides a long list of options, with multiple
* suggestions for each UTC offset.
* – The `minimalTimezoneSet` export provides one option per offset type, with
* a favourite chosen to represent each offset. This is mostly targeted to small,
* western-focused apps. But, every UTC offset is included.
*/
export interface TimezoneEntry {
/** a string from '-11:00' to '+14:00' representing the UTC offset */
offset: string;
/** a readable label that contains the offset and a longer, descriptive name of the timezone */
label: string;
/** the value from the tz standard */
tzCode: string;
}

export declare var defaultTimezoneSet: TimezoneEntry[];
export declare var minimalTimezoneSet: TimezoneEntry[];
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
*
*
* Example:
* import timezones from 'compact-timezone-list';
* const { defaultTimezoneSet } = require('compact-timezone-list');
* // or
* import { minimalTimezoneSet } from 'compact-timezone-list';
* const { minimalTimezoneSet } = require('compact-timezone-list');
*
* Details:
* - The default export provides a long list of options, with multiple
* - The 'defaultTimezoneSet' export provides a long list of options, with multiple
* suggestions for each UTC offset.
* – The `minimalTimezoneSet` export provides one option per offset type, with
* a favourite chosen to represent each offset. This is mostly targeted to small,
Expand All @@ -33,7 +33,7 @@
*
* @type {Array.<{ offset: string, label: string, tzCode: string }>}
*/
export default [
module.exports.defaultTimezoneSet = [
{ offset: '-11:00', label: '(GMT-11:00) Niue', tzCode: 'Pacific/Niue' },
{ offset: '-11:00', label: '(GMT-11:00) Pago Pago', tzCode: 'Pacific/Pago_Pago' },
{ offset: '-10:00', label: '(GMT-10:00) Hawaii Time', tzCode: 'Pacific/Honolulu' },
Expand Down Expand Up @@ -290,7 +290,7 @@ export default [
*
* @type {Array.<{ offset: string, label: string, tzCode: string }>}
*/
export var minimalTimezoneSet = [
module.exports.minimalTimezoneSet = [
{ offset: '-11:00', label: '(GMT-11:00) Pago Pago', tzCode: 'Pacific/Pago_Pago' },
{ offset: '-10:00', label: '(GMT-10:00) Hawaii Time', tzCode: 'Pacific/Honolulu' },
{ offset: '-10:00', label: '(GMT-10:00) Tahiti', tzCode: 'Pacific/Tahiti' },
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"name": "compact-timezone-list",
"version": "1.0.6",
"version": "2.0.0",
"description": "Array of timezones with their labels, tz code, and UTC/GMT offsets.",
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"exports": {
"require": "./index.js",
"import": "./esm/esm.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/filipdanic/compact-timezone-list.git"
Expand Down