Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

generate-timezone-json

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generate-timezone-json - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

zone.tab

55

index.js

@@ -0,6 +1,5 @@

const fs = require("fs");
const fs = require('fs');
console.log("Generating Timezone JSON");
console.log('Generating Timezone JSON');
const args = process.argv;

@@ -10,12 +9,46 @@

// no file
const tzdb = require('@vvo/tzdb');
console.log('... from IANA Database');
const data = tzdb.getTimeZones({includeUtc: true});
fs.writeFile('timezones.json', JSON.stringify(data), (err) => {
const tzdb = require("@vvo/tzdb");
console.log("... from IANA Database");
const data = JSON.stringify(tzdb.getTimeZones({ includeUtc: true }).sort(compare));
writeToFile(data);
} else {
// file name
const fileName = args[2];
const parseZonetab = require("parse-zonetab");
console.log("... from file", fileName);
fs.readFile(fileName, (err, raw) => {
if (err) throw err;
console.log('... done writing to file: timezones.json');
parseZonetab(raw).then(rows => {
const data = JSON.stringify(rows.sort(compare));
writeToFile(data);
});
});
} else {
const fileName = args[2]
console.log('... from file', fileName);
}
function writeToFile(data) {
fs.writeFile("timezones.json", data, (err) => {
if (err) throw err;
console.log("... done writing to file: timezones.json");
});
}
function compare(a, b) {
const bid = b.id || b.name;
const aid = a.id || a.name;
if (aid < bid) {
return -1;
}
if (aid > bid) {
return 1;
}
return 0;
};
{
"name": "generate-timezone-json",
"version": "0.0.3",
"version": "0.0.4",
"description": "Generate JSON file containing timezones from a tab file or the official IANA database",

@@ -10,2 +10,5 @@ "main": "index.js",

},
"bin": {
"generate-timezone-json": "./index.js"
},
"repository": {

@@ -12,0 +15,0 @@ "type": "git",

9

README.md

@@ -10,9 +10,12 @@ # Generate Timezone JSON

- this will generate a file named "timezones.json" with data coming from the official IANA database
1. Run: `generate-timezone-json <filename>` to generate timezones.json from a TAB file,
- for example, using a file named "zone.tab": `generate-timezone-json zone.tab`
### Gotchas
1. Note that the structure of the generated JSON file will be different depending on the source (i.e, zone.tab or the IANA timezones database)
### Planned features (not yet implemented)
1. To generate timezones.json from a TAB file, run: `generate-timezone-json <filename>`
- for example, using a file named "zone.tab": `generate-timezone-json zone.tab`
2. Specify an output directory with option `--outDir`: `generate-timezone <filename> --outDir <directory>`
1. Specify an output directory with option `--outDir`: `generate-timezone <filename> --outDir <directory>`

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc