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

react-timezone-select

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-timezone-select - npm Package Compare versions

Comparing version 1.5.4 to 1.5.5

11

dist/index.d.ts

@@ -21,2 +21,3 @@ import { Props as Props$1 } from 'react-select';

timezones?: ICustomTimezone
maxAbbrLength?: number
}

@@ -26,4 +27,12 @@

declare const TimezoneSelect: ({ value, onBlur, onChange, labelStyle, timezones, ...props }: Props) => JSX.Element;
declare const TimezoneSelect: ({
value,
onBlur,
onChange,
labelStyle,
timezones,
maxAbbrLength,
...props
}: Props) => JSX.Element
export { ILabelStyle, ITimezone, ITimezoneOption, Props, allTimezones, TimezoneSelect as default };

69

dist/index.js

@@ -98,2 +98,3 @@ // src/index.tsx

timezones,
maxAbbrLength = 4,
...props

@@ -105,38 +106,36 @@ }) => {

return Object.entries(timezones).reduce((selectOptions, zone) => {
const now = spacetime.now(zone[0]);
const tz = now.timezone();
const tzStrings = soft(zone[0]);
let label = "";
let abbr = now.isDST() ? (
// @ts-expect-error
tzStrings[0].daylight?.abbr
) : (
// @ts-expect-error
tzStrings[0].standard?.abbr
);
let altName = now.isDST() ? tzStrings[0].daylight?.name : tzStrings[0].standard?.name;
const min = tz.current.offset * 60;
const hr = `${min / 60 ^ 0}:` + (min % 60 === 0 ? "00" : Math.abs(min % 60));
const prefix = `(GMT${hr.includes("-") ? hr : `+${hr}`}) ${zone[1]}`;
switch (labelStyle) {
case "original":
label = prefix;
break;
case "altName":
label = `${prefix} ${altName?.length ? `(${altName})` : ""}`;
break;
case "abbrev":
label = `${prefix} ${abbr?.length < 5 ? `(${abbr})` : ""}`;
break;
default:
label = `${prefix}`;
try {
const now = spacetime.now(zone[0]);
const tz = now.timezone();
const tzStrings = soft(zone[0]);
let label = "";
let abbr = now.isDST() ? tzStrings[0].daylight.abbr : tzStrings[0].standard.abbr;
let altName = now.isDST() ? tzStrings[0].daylight.name : tzStrings[0].standard.name;
const min = tz.current.offset * 60;
const hr = `${min / 60 ^ 0}:` + (min % 60 === 0 ? "00" : Math.abs(min % 60));
const prefix = `(GMT${hr.includes("-") ? hr : `+${hr}`}) ${zone[1]}`;
switch (labelStyle) {
case "original":
label = prefix;
break;
case "altName":
label = `${prefix} ${altName?.length ? `(${altName})` : ""}`;
break;
case "abbrev":
label = `${prefix} (${abbr.substring(0, maxAbbrLength)})`;
break;
default:
label = `${prefix}`;
}
selectOptions.push({
value: tz.name,
label,
offset: tz.current.offset,
abbrev: abbr,
altName
});
return selectOptions;
} catch {
return selectOptions;
}
selectOptions.push({
value: tz.name,
label,
offset: tz.current.offset,
abbrev: abbr,
altName
});
return selectOptions;
}, []).sort((a, b) => a.offset - b.offset);

@@ -143,0 +142,0 @@ }, [labelStyle, timezones]);

{
"name": "react-timezone-select",
"version": "1.5.4",
"version": "1.5.5",
"description": "Usable, dynamic React Timezone Select",
"scripts": {
"dev": "concurrently \"rollup -cw\" \"cd example && npm run dev\"",
"prepublish": "npm run build",
"postpublish": "npm run build:example && npm run deploy",
"dev": "concurrently \"tsup src/index.tsx --format esm --watch\" \"cd example && npm run dev\"",
"prepublishOnly": "pnpm run build",
"postpublish": "pnpm run build:example && npm run deploy",
"build": "tsup src/index.tsx --format cjs,esm --dts",
"build:example": "cd example && npm run build",
"build:example": "cd example && pnpm run build",
"deploy": "gh-pages -d example/dist",
"pretest": "pnpm run build",
"test": "jest",
"test:watch": "jest --watch",
"test:ci": "jest --ci ",
"test:ci": "pnpm run build && jest --ci ",
"tsc": "tsc"

@@ -54,4 +55,4 @@ },

"react-select": "^5.7.0",
"spacetime": "^7.1.4",
"timezone-soft": "^1.3.1"
"spacetime": "^7.4.1",
"timezone-soft": "^1.4.1"
},

@@ -58,0 +59,0 @@ "devDependencies": {

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