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.1.6 to 0.2.0

51

index.js
#!/usr/bin/env node
const fs = require('fs');
const args = process.argv;
console.log("Generating Timezone JSON");
const args = process.argv;
if (args.length < 3) {
// no file
const tzdb = require("@vvo/tzdb");
const data = JSON.stringify(tzdb.getTimeZones({ includeUtc: true }));
console.log("... from IANA Database");
const data = JSON.stringify(tzdb.getTimeZones({ includeUtc: true }));
writeToFile(data);

@@ -18,21 +18,30 @@ } else {

const fileName = args[2];
const parseZonetab = require("parse-zonetab");
console.log("... from file", fileName);
if (isTabFile(fileName)) {
const parseZonetab = require("parse-zonetab");
fs.readFile(fileName, (err, raw) => {
fs.readFile(fileName, (err, raw) => {
if (err) throw err;
parseZonetab(raw).then(rows => {
const data = JSON.stringify(rows);
console.log("... from file", fileName);
writeToFile(data);
});
if (err) throw err;
parseZonetab(raw).then(rows => {
const data = JSON.stringify(rows);
writeToFile(data);
});
} else {
console.error('Error: input not a TAB file', fileName)
}
}
function isTabFile(fileName) {
if (!!fileName && fileName !== '') {
const extension = fileName.split('.')[1];
return extension === 'tab';
}
});
return false;
}
function writeToFile(data) {
fs.writeFile("timezones.json", data, (err) => {

@@ -43,17 +52,1 @@ if (err) throw err;

}
/*
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.1.6",
"version": "0.2.0",
"bin": "./index.js",

@@ -5,0 +5,0 @@ "description": "Generate JSON file containing timezones from a tab file or the official IANA database",

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