New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cashstar/react-timezone

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cashstar/react-timezone - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

_gh-pages/static/manager.96c92a5503fede7cc6c6.bundle.js

2

jest.config.js

@@ -9,3 +9,3 @@ module.exports = {

verbose: true,
setupTestFrameworkScriptFile: '<rootDir>/testSetup.js'
setupTestFrameworkScriptFile: '<rootDir>/test/testSetup.js'
};

@@ -21,3 +21,3 @@ 'use strict';

// We want to subset the existing timezone data as much as possible, both for efficiency
// and to avoid confusing the user. Here, we focus on removing reduntant timezone names
// and to avoid confusing the user. Here, we focus on removing redundant timezone names
// and timezone names for timezones we don't necessarily care about, like Antarctica, and

@@ -28,8 +28,20 @@ // special timezone names that exist for convenience.

return _momentTimezone2.default.tz.names().filter(function (name) {
return name.indexOf('/') >= 0;
}).filter(function (name) {
return !scrubbedPrefixes.indexOf(name.split('/')[0]) >= 0;
}).filter(function (name) {
return !scrubbedSuffixes.indexOf(name.split('/').slice(-1)[0]) >= 0;
var getZoneName = function getZoneName(zone) {
return typeof zone === 'string' ? zone.split('|')[0] : zone.name;
};
var onlyCanonicalZones = function onlyCanonicalZones(zone) {
return zone.indexOf('/') >= 0;
};
var nonBlacklistedPrefixes = function nonBlacklistedPrefixes(zone) {
return !(scrubbedPrefixes.indexOf(zone.split('/')[0]) >= 0);
};
var nonBlacklistedSuffixes = function nonBlacklistedSuffixes(zone) {
return !(scrubbedSuffixes.indexOf(zone.split('/').slice(-1)[0]) >= 0);
};
// Filter using _zones in this manner in order to reduce the number of duplicated and deprecated timezone names
// until moment-timezone provides a better way: https://github.com/moment/moment-timezone/issues/227
return Object.values(_momentTimezone2.default.tz._zones) // eslint-disable-line no-underscore-dangle
.map(getZoneName).filter(function (zone) {
return onlyCanonicalZones(zone) && nonBlacklistedPrefixes(zone) && nonBlacklistedSuffixes(zone);
});

@@ -36,0 +48,0 @@ }();

@@ -80,4 +80,4 @@ 'use strict';

// return GMT if we're unable to guess or the system is using UTC
if (!userTz || userTz === 'UTC') return (0, _func.head)(tzSearch({ zoneName: 'Etc/Greenwich' }));
// return UTC if we're unable to guess or the system is using UTC
if (!userTz || userTz === 'UTC') return (0, _func.head)(tzSearch({ zoneName: 'Etc/UTC' }));

@@ -84,0 +84,0 @@ return (0, _func.head)(tzSearch({ zoneName: userTz }));

{
"name": "@cashstar/react-timezone",
"version": "2.0.4",
"version": "2.0.5",
"description": "A timezone picker widget in React",

@@ -16,2 +16,3 @@ "main": "index.js",

"test:nocache": "jest --no-cache",
"test:security": "snyk test",
"test:watch": "jest --watch",

@@ -30,3 +31,3 @@ "coveralls": "jest --coverage && cat ./coverage/lcov.info | coveralls",

"postversion": "git commit package.json -m \"Version $npm_package_version\" && npm run tag && git push && git push --tags && npm publish --registry=https://registry.npmjs.org/",
"prepublish": "npm run build",
"prepublishOnly": "npm run build",
"postpublish": "npm run gh-pages"

@@ -49,3 +50,3 @@ },

"classnames": "^2.2.5",
"coveralls": "^3.0.0",
"coveralls": "^3.0.3",
"git-directory-deploy": "^1.5.1",

@@ -58,3 +59,3 @@ "invariant": "^2.2.2",

"@storybook/addon-knobs": "3.2.8",
"@storybook/react": "3.2.8",
"@storybook/react": "^3.4.11",
"babel-cli": "^6.26.0",

@@ -80,4 +81,4 @@ "babel-core": "^6.26.0",

"jsdom": "^11.2.0",
"moment": "^2.20.1",
"moment-timezone": "^0.5.14",
"moment": "^2.24.0",
"moment-timezone": "^0.5.25",
"prop-types": "^15.5.10",

@@ -89,3 +90,4 @@ "react": "^15.6.2",

"rimraf": "^2.6.1",
"semver": "^5.4.1"
"semver": "^5.4.1",
"snyk": "^1.167.2"
},

@@ -92,0 +94,0 @@ "peerDependencies": {

@@ -10,3 +10,3 @@ import moment from 'moment-timezone';

// We want to subset the existing timezone data as much as possible, both for efficiency
// and to avoid confusing the user. Here, we focus on removing reduntant timezone names
// and to avoid confusing the user. Here, we focus on removing redundant timezone names
// and timezone names for timezones we don't necessarily care about, like Antarctica, and

@@ -17,6 +17,16 @@ // special timezone names that exist for convenience.

return moment.tz.names()
.filter(name => name.indexOf('/') >= 0)
.filter(name => !scrubbedPrefixes.indexOf(name.split('/')[0]) >= 0)
.filter(name => !scrubbedSuffixes.indexOf(name.split('/').slice(-1)[0]) >= 0);
const getZoneName = zone => ((typeof zone === 'string') ? zone.split('|')[0] : zone.name);
const onlyCanonicalZones = zone => zone.indexOf('/') >= 0;
const nonBlacklistedPrefixes = zone => !(scrubbedPrefixes.indexOf(zone.split('/')[0]) >= 0);
const nonBlacklistedSuffixes = zone => !(scrubbedSuffixes.indexOf(zone.split('/').slice(-1)[0]) >= 0);
// Filter using _zones in this manner in order to reduce the number of duplicated and deprecated timezone names
// until moment-timezone provides a better way: https://github.com/moment/moment-timezone/issues/227
return Object.values(moment.tz._zones) // eslint-disable-line no-underscore-dangle
.map(getZoneName)
.filter(zone =>
onlyCanonicalZones(zone)
&& nonBlacklistedPrefixes(zone)
&& nonBlacklistedSuffixes(zone)
);
})();

@@ -23,0 +33,0 @@

@@ -62,4 +62,4 @@ import moment from 'moment-timezone';

// return GMT if we're unable to guess or the system is using UTC
if (!userTz || userTz === 'UTC') return head(tzSearch({ zoneName: 'Etc/Greenwich' }));
// return UTC if we're unable to guess or the system is using UTC
if (!userTz || userTz === 'UTC') return head(tzSearch({ zoneName: 'Etc/UTC' }));

@@ -66,0 +66,0 @@ return head(tzSearch({ zoneName: userTz }));

@@ -1,7 +0,7 @@

import moment from 'moment';
import moment from 'moment-timezone';
const IS_DAYLIGHT_SAVING = moment().isDST();
export const EASTERN_TZ = IS_DAYLIGHT_SAVING ? 'EDT' : 'EST';
export const PACIFIC_TZ = IS_DAYLIGHT_SAVING ? 'PDT' : 'PST';
export const CENTRAL_TZ = IS_DAYLIGHT_SAVING ? 'CDT' : 'CST';
export const NEWFOUNDLAND_TZ = IS_DAYLIGHT_SAVING ? 'NDT' : 'NST';
const isDaylightSaving = timezone => moment().tz(timezone).isDST();
export const EASTERN_TZ = isDaylightSaving('America/New_York') ? 'EDT' : 'EST';
export const PACIFIC_TZ = isDaylightSaving('America/Los_Angeles') ? 'PDT' : 'PST';
export const CENTRAL_TZ = isDaylightSaving('America/Chicago') ? 'CDT' : 'CST';
export const NEWFOUNDLAND_TZ = isDaylightSaving('America/St_Johns') ? 'NDT' : 'NST';

@@ -5,5 +5,3 @@ import tzMaps from '../../src/data/timezoneData';

EASTERN_TZ,
PACIFIC_TZ,
CENTRAL_TZ,
NEWFOUNDLAND_TZ
CENTRAL_TZ
} from '../testUtils';

@@ -97,5 +95,3 @@

{ city: 'New York', zoneName: 'America/New_York', zoneAbbr: EASTERN_TZ },
{ city: 'New Salem', zoneName: 'America/North_Dakota/New_Salem', zoneAbbr: CENTRAL_TZ },
{ city: 'Canada/Newfoundland', zoneName: 'Canada/Newfoundland', zoneAbbr: NEWFOUNDLAND_TZ },
{ city: 'US/Pacific-New', zoneName: 'US/Pacific-New', zoneAbbr: PACIFIC_TZ }
{ city: 'New Salem', zoneName: 'America/North_Dakota/New_Salem', zoneAbbr: CENTRAL_TZ }
]);

@@ -132,5 +128,3 @@ });

'New York',
'New Salem',
'Canada/Newfoundland',
'US/Pacific-New'
'New Salem'
]);

@@ -137,0 +131,0 @@ });

@@ -18,5 +18,5 @@ /* eslint-disable max-len */ // lots of long test names and that's ok

const greenwhichTimezone = {
city: 'Greenwich',
zoneAbbr: 'GMT',
zoneName: 'Etc/Greenwich'
city: 'UTC',
zoneAbbr: 'UTC',
zoneName: 'Etc/UTC'
};

@@ -127,7 +127,3 @@ const mockMobileUserAgent = 'Mozilla/5.0 (Linux; Android 4.4.2; GT-I9515L Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36';

window.navigator.userAgent = mockMobileUserAgent;
window.Intl.DateTimeFormat = jest.fn().mockImplementation(
() => {
resolvedOptions: mockResolvedOptions
}
);
window.Intl.DateTimeFormat = jest.fn();
});

@@ -164,3 +160,3 @@

it('returns the GMT timezone', () => {
it('returns the UTC timezone', () => {
expect(guessedTimezone).toEqual(greenwhichTimezone);

@@ -182,3 +178,3 @@ });

it('returns the GMT timezone', () => {
it('returns the UTC timezone', () => {
expect(guessedTimezone).toEqual(greenwhichTimezone);

@@ -220,3 +216,3 @@ });

it('returns the GMT timezone', () => {
it('returns the UTC timezone', () => {
expect(timeHelper.guessUserTz()).toEqual(greenwhichTimezone);

@@ -231,3 +227,3 @@ });

it('returns the GMT timezone', () => {
it('returns the UTC timezone', () => {
expect(timeHelper.guessUserTz()).toEqual(greenwhichTimezone);

@@ -258,3 +254,3 @@ });

it('returns the GMT timezone', () => {
it('returns the UTC timezone', () => {
expect(timeHelper.guessUserTz()).toEqual(greenwhichTimezone);

@@ -269,3 +265,3 @@ });

it('returns the GMT timezone', () => {
it('returns the UTC timezone', () => {
expect(timeHelper.guessUserTz()).toEqual(greenwhichTimezone);

@@ -272,0 +268,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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