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

simpler-timezones

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simpler-timezones - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

22

distributions/cjs/simplerTimezones.js

@@ -7,3 +7,2 @@ "use strict";

var timezones_1 = __importDefault(require("./data-for-code/timezones"));
var moment_timezone_1 = __importDefault(require("moment-timezone"));
var SimplerTimezones = /** @class */ (function () {

@@ -13,19 +12,24 @@ function SimplerTimezones(options) {

this.getTimezone = function (offset) {
return timezones_1.default.find(function (timezone) { return timezone.offset_standard === offset; });
return _this.simplerTimezones.find(function (timezone) { return timezone.offset_standard === offset; });
};
this.getTimezones = function () {
if (_this.showMoreTimezones) {
return timezones_1.default;
}
return timezones_1.default.filter(function (timezone) { return timezone.show_by_default; });
return _this.simplerTimezones;
};
this.guessLocale = function () {
return moment_timezone_1.default.tz.guess();
try {
return Intl.DateTimeFormat().resolvedOptions().timeZone || '';
}
catch (e) {
console.log('Browser does not support timezone detection');
return '';
}
};
this.guessTimezone = function () {
return timezones_1.default.find(function (timezone) {
return _this.simplerTimezones.find(function (timezone) {
return timezone['locales'].includes(_this.guessLocale());
});
};
this.showMoreTimezones = options === null || options === void 0 ? void 0 : options.showMoreTimezones;
this.simplerTimezones = (options === null || options === void 0 ? void 0 : options.showMoreTimezones)
? timezones_1.default
: timezones_1.default.filter(function (timezone) { return timezone.show_by_default; });
}

@@ -32,0 +36,0 @@ return SimplerTimezones;

import timezones from './data-for-code/timezones';
import moment from 'moment-timezone';
var SimplerTimezones = /** @class */ (function () {

@@ -7,19 +6,24 @@ function SimplerTimezones(options) {

this.getTimezone = function (offset) {
return timezones.find(function (timezone) { return timezone.offset_standard === offset; });
return _this.simplerTimezones.find(function (timezone) { return timezone.offset_standard === offset; });
};
this.getTimezones = function () {
if (_this.showMoreTimezones) {
return timezones;
}
return timezones.filter(function (timezone) { return timezone.show_by_default; });
return _this.simplerTimezones;
};
this.guessLocale = function () {
return moment.tz.guess();
try {
return Intl.DateTimeFormat().resolvedOptions().timeZone || '';
}
catch (e) {
console.log('Browser does not support timezone detection');
return '';
}
};
this.guessTimezone = function () {
return timezones.find(function (timezone) {
return _this.simplerTimezones.find(function (timezone) {
return timezone['locales'].includes(_this.guessLocale());
});
};
this.showMoreTimezones = options === null || options === void 0 ? void 0 : options.showMoreTimezones;
this.simplerTimezones = (options === null || options === void 0 ? void 0 : options.showMoreTimezones)
? timezones
: timezones.filter(function (timezone) { return timezone.show_by_default; });
}

@@ -26,0 +30,0 @@ return SimplerTimezones;

@@ -0,1 +1,2 @@

import timezones from './data-for-code/timezones';
interface Options {

@@ -5,3 +6,3 @@ showMoreTimezones?: boolean;

declare class SimplerTimezones {
showMoreTimezones?: boolean;
simplerTimezones: typeof timezones;
constructor(options?: Options);

@@ -8,0 +9,0 @@ getTimezone: (offset: number) => import("./data-for-code/timezones").Timezone | undefined;

{
"name": "simpler-timezones",
"version": "0.0.1",
"version": "0.1.0",
"description": "a simpler list of timezones, and tools for reasonably guessing the nearest major timezone to a user",

@@ -45,5 +45,2 @@ "main": "distributions/cjs/index.js",

},
"dependencies": {
"moment-timezone": "0.5.34"
},
"devDependencies": {

@@ -50,0 +47,0 @@ "@commitlint/cli": "^13.1.0",

<p align="center">
<img src="./source/data-for-humans/simpler.jpg" width="450">
<br>
<br>
SIMPLER TIMEZONES
<br>
a simpler list of timezones, and tools for reasonably guessing the nearest timezone to a user
<br>
<br>
<a href="https://codesandbox.io/s/upbeat-tdd-ferbl?fontsize=14&hidenavigation=1&theme=dark">
<img src="https://codesandbox.io/static/img/play-codesandbox.svg">
</a>
</p>

@@ -8,0 +15,0 @@

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