feat: expose the tzdb version of the bundled zonefile
This commit is contained in:
1 parent
d47824c8f3
commit
1668c0dd6b
7 files changed
+22
-3
No files matched your search
@@ -187,7 +187,7 @@ export const main = (args = process.argv.slice(2)) => {
|
|||||||
tzdata: version,
|
tzdata: version,
|
||||||
unsupported: unsupported.map((o) => o.name)
|
unsupported: unsupported.map((o) => o.name)
|
||||||
})
|
})
|
||||||
const text = `// Generated by scripts/tz/update.js: ${source}\nexport default ${JSON.stringify(result, null, 2)}\n`
|
const text = `// Generated by scripts/tz/update.js: ${source}\nexport const tzdbVersion = ${JSON.stringify(version)}\nexport default ${JSON.stringify(result, null, 2)}\n`
|
||||||
// Rename within the destination directory so readers never see a partial file.
|
// Rename within the destination directory so readers never see a partial file.
|
||||||
// Only remove a temporary file created by this run (exclusive creation may fail).
|
// Only remove a temporary file created by this run (exclusive creation may fail).
|
||||||
const temporary = join(dirname(options.output), `.zonefile-${process.pid}.tmp`)
|
const temporary = join(dirname(options.output), `.zonefile-${process.pid}.tmp`)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import Spacetime from './spacetime.js'
|
import Spacetime from './spacetime.js'
|
||||||
import whereIts from './whereIts.js'
|
import whereIts from './whereIts.js'
|
||||||
import version from './_version.js'
|
import version from './_version.js'
|
||||||
|
import { tzdbVersion } from '../zonefile/_build.js'
|
||||||
|
|
||||||
const main = (input, tz, options) => new Spacetime(input, tz, options)
|
const main = (input, tz, options) => new Spacetime(input, tz, options)
|
||||||
|
|
||||||
@@ -62,6 +63,7 @@ main.min = function (tz, options) {
|
|||||||
//find tz by time
|
//find tz by time
|
||||||
main.whereIts = whereIts
|
main.whereIts = whereIts
|
||||||
main.version = version
|
main.version = version
|
||||||
|
main.tzdbVersion = tzdbVersion
|
||||||
|
|
||||||
//aliases:
|
//aliases:
|
||||||
main.plugin = main.extend
|
main.plugin = main.extend
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import test from 'tape'
|
||||||
|
import spacetime from './lib/index.js'
|
||||||
|
import { tzdbVersion } from '../zonefile/iana.js'
|
||||||
|
|
||||||
|
test('tzdb version', (t) => {
|
||||||
|
t.ok(/^\d{4}[a-z]+$/.test(spacetime.tzdbVersion), `looks like '2026c'`)
|
||||||
|
t.equal(spacetime.tzdbVersion, tzdbVersion, 'same as zonefile/iana.js')
|
||||||
|
t.end()
|
||||||
|
})
|
||||||
Vendored
+3
@@ -86,6 +86,9 @@ export interface SpacetimeStatic extends SpacetimeConstructor {
|
|||||||
/** list timezones by their time */
|
/** list timezones by their time */
|
||||||
whereIts: (a: string, b?: string) => string[]
|
whereIts: (a: string, b?: string) => string[]
|
||||||
|
|
||||||
|
/** IANA tzdb release of the bundled timezone data, like '2026c' */
|
||||||
|
tzdbVersion: string
|
||||||
|
|
||||||
/** set as earliest-possible date */
|
/** set as earliest-possible date */
|
||||||
min: (timezone?: string, options?: SpacetimeConstructorOptions) => Spacetime
|
min: (timezone?: string, options?: SpacetimeConstructorOptions) => Spacetime
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
export const tzdbVersion = "2026c"
|
||||||
export default {
|
export default {
|
||||||
"9|s": "2/dili,2/jayapura",
|
"9|s": "2/dili,2/jayapura",
|
||||||
"9|n": "2/chita,2/khandyga,2/pyongyang,2/seoul,2/tokyo,2/yakutsk,11/palau,japan,rok",
|
"9|n": "2/chita,2/khandyga,2/pyongyang,2/seoul,2/tokyo,2/yakutsk,11/palau,japan,rok",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
export const tzdbVersion = '2026c'
|
||||||
export default {
|
export default {
|
||||||
'africa/abidjan': {
|
'africa/abidjan': {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
|
|||||||
+5
-2
@@ -1,6 +1,6 @@
|
|||||||
//turn our timezone data into a small-as-possible string
|
//turn our timezone data into a small-as-possible string
|
||||||
import { writeFileSync } from 'node:fs'
|
import { writeFileSync } from 'node:fs'
|
||||||
import iana from './iana.js'
|
import iana, { tzdbVersion } from './iana.js'
|
||||||
import aliases from './aliases.js'
|
import aliases from './aliases.js'
|
||||||
import prefixes from './_prefixes.js'
|
import prefixes from './_prefixes.js'
|
||||||
const all = {}
|
const all = {}
|
||||||
@@ -44,4 +44,7 @@ keys.forEach((k) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// console.log(result)
|
// console.log(result)
|
||||||
writeFileSync('./zonefile/_build.js', 'export default ' + JSON.stringify(result, null, 2))
|
writeFileSync(
|
||||||
|
'./zonefile/_build.js',
|
||||||
|
`export const tzdbVersion = ${JSON.stringify(tzdbVersion)}\nexport default ${JSON.stringify(result, null, 2)}`
|
||||||
|
)
|
||||||
Reference in new issue
Block a user