Skip to content

Commit

Permalink
feat: Expose alias timezones links
Browse files Browse the repository at this point in the history
  • Loading branch information
econdepe authored and prantlf committed Dec 4, 2022
1 parent 2a8bd0e commit ac83d20
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.idea
coverage
dist
examples/**/out
Expand Down
5 changes: 3 additions & 2 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface SetTimeZoneOptions {
}

declare function listTimeZones (): Array<string>
declare function getTimeZoneLinks (): { [alias: string]: string }
declare function findTimeZone (name: string): TimeZoneInfo

declare function getUTCOffset (date: DateInput, timeZone: TimeZoneInfo): TimeZoneOffset
Expand All @@ -42,8 +43,8 @@ declare function convertTimeToDate (time: Time): Date
declare function convertDateToTime (date: Date): Time

export {
listTimeZones, findTimeZone, getUTCOffset, getZonedTime, getUnixTime,
setTimeZone, convertTimeToDate, convertDateToTime
listTimeZones, getTimeZoneLinks, findTimeZone, getUTCOffset, getZonedTime,
getUnixTime, setTimeZone, convertTimeToDate, convertDateToTime
}

// export as namespace timezoneSupport;
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
populateTimeZones, listTimeZones, findTimeZone, getUTCOffset, getZonedTime,
getUnixTime, setTimeZone, convertTimeToDate, convertDateToTime
populateTimeZones, listTimeZones, getTimeZoneLinks, findTimeZone, getUTCOffset,
getZonedTime, getUnixTime, setTimeZone, convertTimeToDate, convertDateToTime
} from './lookup-convert'
import data from './lookup/data'

populateTimeZones(data)

export {
listTimeZones, findTimeZone, getUTCOffset, getZonedTime, getUnixTime,
setTimeZone, convertTimeToDate, convertDateToTime
listTimeZones, getTimeZoneLinks, findTimeZone, getUTCOffset, getZonedTime,
getUnixTime, setTimeZone, convertTimeToDate, convertDateToTime
}
5 changes: 3 additions & 2 deletions src/lookup-convert.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface TimeZoneData {

declare function populateTimeZones (TimeZoneData): void
declare function listTimeZones (): Array<string>
declare function getTimeZoneLinks (): { [alias: string]: string }
declare function findTimeZone (name: string): TimeZoneInfo

declare function getUTCOffset (date: DateInput, timeZone: TimeZoneInfo): TimeZoneOffset
Expand All @@ -48,8 +49,8 @@ declare function convertTimeToDate (time: Time): Date
declare function convertDateToTime (date: Date): Time

export {
populateTimeZones, listTimeZones, findTimeZone, getUTCOffset, getZonedTime,
getUnixTime, setTimeZone, convertTimeToDate, convertDateToTime
populateTimeZones, listTimeZones, getTimeZoneLinks, findTimeZone, getUTCOffset,
getZonedTime, getUnixTime, setTimeZone, convertTimeToDate, convertDateToTime
}

// export as namespace timezoneLookupConvert;
2 changes: 1 addition & 1 deletion src/lookup-convert.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { populateTimeZones, listTimeZones, findTimeZone } from './lookup/lookup'
export { populateTimeZones, listTimeZones, getTimeZoneLinks, findTimeZone } from './lookup/lookup'
export { getUTCOffset, getZonedTime, getUnixTime, setTimeZone, convertTimeToDate, convertDateToTime } from './convert/convert'
6 changes: 5 additions & 1 deletion src/lookup/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ function listTimeZones () {
return names.slice()
}

function getTimeZoneLinks () {
return Object.assign({}, links)
}

function findTimeZone (alias) {
const name = links[alias] || alias
let timeZone = instances[name]
Expand All @@ -37,4 +41,4 @@ function findTimeZone (alias) {
return timeZone
}

export { populateTimeZones, listTimeZones, findTimeZone }
export { populateTimeZones, listTimeZones, getTimeZoneLinks, findTimeZone }

0 comments on commit ac83d20

Please sign in to comment.