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

isoly

Package Overview
Dependencies
Maintainers
2
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isoly - npm Package Compare versions

Comparing version 2.0.16 to 2.0.17

dist/TimeZoneOffset.d.ts

1

dist/Date.js

@@ -31,2 +31,3 @@ export var Date;

.substring(0, 10)
// See DateTime:localize for note.
.replaceAll(" ", " "));

@@ -33,0 +34,0 @@ }

7

dist/DateTime.d.ts

@@ -5,2 +5,3 @@ import { Date } from "./Date";

import { TimeZone } from "./TimeZone";
import { TimeZoneOffset } from "./TimeZoneOffset";
export type DateTime = string;

@@ -14,5 +15,7 @@ export declare namespace DateTime {

type Format = Intl.DateTimeFormatOptions;
function localize(value: DateTime | globalThis.Date, format: Intl.DateTimeFormatOptions, locale?: Locale): string;
function localize(value: DateTime | globalThis.Date, format: Format, locale?: Locale): string;
function localize(value: DateTime | globalThis.Date, locale?: Locale, timeZone?: TimeZone): string;
function timeZone(value: DateTime): TimeZone | "";
/** @deprecated Use timeZoneOffset() */
function timeZone(value: DateTime): TimeZoneOffset | "";
function timeZoneOffset(value: DateTime): TimeZoneOffset | "";
function timeZoneShort(value: DateTime): number;

@@ -19,0 +22,0 @@ type Precision = "hours" | "minutes" | "seconds" | "milliseconds";

import { Date } from "./Date";
import { TimeZone } from "./TimeZone";
import { TimeZoneOffset } from "./TimeZoneOffset";
export var DateTime;

@@ -15,2 +15,16 @@ (function (DateTime) {

function is(value) {
// 2019-04-01T01
// 2019-04-01T01Z
// 2019-04-01T01+01:00
// 2019-04-01T01:11
// 2019-04-01T01:11Z
// 2019-04-01T01:11+01:00
// 2019-04-01T01:11:29
// 2019-04-01T01:11:29Z
// 2019-04-01T01:11:29+01:00
// 2019-04-01T01:11:29.000
// 2019-04-01T01:11:29.000Z
// 2019-04-01T01:11:29.000+01:00
// 01234567890123456789012345678
// 0 1 2
return (typeof value == "string" &&

@@ -23,3 +37,3 @@ value.length >= 13 &&

(value.length == 13 ||
TimeZone.is(value.substring(13)) ||
TimeZoneOffset.is(value.substring(13)) ||
(value[13] == ":" &&

@@ -29,3 +43,3 @@ value.length >= 16 &&

(value.length == 16 ||
TimeZone.is(value.substring(16)) ||
TimeZoneOffset.is(value.substring(16)) ||
(value[16] == ":" &&

@@ -35,7 +49,7 @@ value.length >= 19 &&

(value.length == 19 ||
TimeZone.is(value.substring(19)) ||
TimeZoneOffset.is(value.substring(19)) ||
(value[19] == "." &&
value.length >= 23 &&
[...value.substring(20, 23)].every(c => c >= "0" && c <= "9") &&
(value.length == 23 || TimeZone.is(value.substring(23))))))))));
(value.length == 23 || TimeZoneOffset.is(value.substring(23))))))))));
}

@@ -52,8 +66,12 @@ DateTime.is = is;

value = value * 24;
// fallthrough...
case "hours":
value = value * 60;
// fallthrough...
case "minutes":
value = value * 60;
// fallthrough...
case "seconds":
value = value * 1000;
// fallthrough...
case "milliseconds":

@@ -70,11 +88,20 @@ }

DateTime.now = now;
function localize(value, locale, timeZone) {
function localize(value, formatOrLocale, localeOrTimeZone) {
let result;
if (typeof locale == "object") {
const localeString = timeZone ? timeZone : Intl.DateTimeFormat().resolvedOptions().locale;
if (typeof formatOrLocale == "object") {
// formatOrLocale is Format
// localeOrTimeZone is Locale | undefined
const localeString = localeOrTimeZone ? localeOrTimeZone : Intl.DateTimeFormat().resolvedOptions().locale;
result = (is(value) ? parse(value) : value)
.toLocaleString(localeString, locale)
.toLocaleString(localeString, formatOrLocale)
// For consistency, replace NNBSP with space:
// Unicode has decided to use `Narrow No-Break Space (NNBSP)` (U+202F) instead of space in some cases.
// It breaks tests, when running in different environments.
// https://icu.unicode.org/download/72#:~:text=In%20many%20formatting%20patterns%2C%20ASCII%20spaces%20are%20replaced%20with%20Unicode%20spaces%20(e.g.%2C%20a%20%22thin%20space%22)
// This can be removed, with a breaking change and updated tests, when all systems use updated versions of ICU.
.replaceAll(" ", " ");
}
else {
// formatOrLocale is Locale | undefined
// localeOrTimeZone is timeZone | undefined
const precision = is(value) ? DateTime.precision(value) : "milliseconds";

@@ -88,4 +115,4 @@ result = localize(value, {

second: precision == "seconds" || precision == "milliseconds" ? "2-digit" : undefined,
timeZone: timeZone,
}, locale);
timeZone: localeOrTimeZone,
}, formatOrLocale);
}

@@ -95,7 +122,12 @@ return result;

DateTime.localize = localize;
/** @deprecated Use timeZoneOffset() */
function timeZone(value) {
return timeZoneOffset(value);
}
DateTime.timeZone = timeZone;
function timeZoneOffset(value) {
const result = value[value.length - 1] == "Z" ? "Z" : value.substring(value.length - 6);
return TimeZone.is(result) ? result : "";
return TimeZoneOffset.is(result) ? result : "";
}
DateTime.timeZone = timeZone;
DateTime.timeZoneOffset = timeZoneOffset;
function timeZoneShort(value) {

@@ -106,3 +138,3 @@ return parse(value).getTimezoneOffset();

function precision(value) {
const zone = timeZone(value);
const zone = timeZoneOffset(value);
const time = value.substring(0, value.length - zone.length).split("T", 2)[1];

@@ -129,3 +161,4 @@ let result;

function truncate(value, precision) {
const zone = timeZone(value);
const zone = timeZoneOffset(value);
// eslint-disable-next-line prefer-const
let [date, time] = value.split("T", 2);

@@ -167,8 +200,12 @@ time = time.substring(0, time.length - zone.length);

result = Math.round(result / 24);
// fallthrough...
case "hours":
result = Math.round(result / 60);
// fallthrough...
case "minutes":
result = Math.round(result / 60);
// fallthrough...
case "seconds":
result = Math.round(result / 1000);
// fallthrough...
case "milliseconds":

@@ -271,3 +308,3 @@ }

result.setDate(result.getDate() + days);
result.setMinutes(result.getMinutes() + offset - result.getTimezoneOffset());
result.setMinutes(result.getMinutes() + offset - result.getTimezoneOffset()); // handle changing potential daylight saving time
return DateTime.create(result);

@@ -284,3 +321,3 @@ }

result.setMonth(result.getMonth() + months);
result.setMinutes(result.getMinutes() + offset - result.getTimezoneOffset());
result.setMinutes(result.getMinutes() + offset - result.getTimezoneOffset()); // handle changing potential daylight saving time
return DateTime.create(result);

@@ -360,2 +397,7 @@ }

})(DateTime || (DateTime = {}));
/*
2021-01-10T13:37:42.000Z
012345678901234567890123
0 1 2
*/
//# sourceMappingURL=DateTime.js.map

@@ -121,3 +121,3 @@ import { Iso88591 } from "./Iso88591";

case "ISO 8859-1":
case "ISO-8859-1":
case "ISO-8859-1": // Western Europe
result = "ISO-8859-1";

@@ -127,42 +127,42 @@ break;

result = "ISO-8859-2";
break;
break; // Western and Central Europe
case "ISO-8859-3":
result = "ISO-8859-3";
break;
break; // Western Europe and South European (Turkish, Maltese plus Esperanto)
case "ISO-8859-4":
result = "ISO-8859-4";
break;
break; // Western Europe and Baltic countries (Lithuania, Estonia, Latvia and Lapp)
case "ISO-8859-5":
result = "ISO-8859-5";
break;
break; // Cyrillic alphabet
case "ISO-8859-6":
result = "ISO-8859-6";
break;
break; // Arabic
case "ISO-8859-7":
result = "ISO-8859-7";
break;
break; // Greek
case "ISO-8859-8":
result = "ISO-8859-8";
break;
break; // Hebrew
case "ISO-8859-9":
result = "ISO-8859-9";
break;
break; // Western Europe with amended Turkish character set
case "ISO-8859-10":
result = "ISO-8859-10";
break;
break; // Western Europe with rationalised character set for Nordic languages, including complete Icelandic set
case "ISO-8859-11":
result = "ISO-8859-11";
break;
break; // Thai
case "ISO-8859-13":
result = "ISO-8859-13";
break;
break; // Baltic languages plus Polish
case "ISO-8859-14":
result = "ISO-8859-14";
break;
break; // Celtic languages (Irish Gaelic, Scottish, Welsh)
case "ISO-8859-15":
result = "ISO-8859-15";
break;
break; // Added the Euro sign and other rationalisations to ISO 8859-1
case "ISO-8859-16":
result = "ISO-8859-16";
break;
break; // Central, Eastern and Southern European languages (Albanian, Bosnian, Croatian, Hungarian, Polish, Romanian, Serbian and Slovenian, but also French, German, Italian and Irish Gaelic)
case "CP437":

@@ -218,27 +218,27 @@ result = "CP437";

result = "Windows-1250";
break;
break; // Central European languages that use Latin script, (Polish, Czech, Slovak, Hungarian, Slovene, Serbian, Croatian, Bosnian, Romanian and Albanian)
case "WINDOWS-1251":
result = "Windows-1251";
break;
break; // Cyrillic alphabets
case "WINDOWS-1252":
result = "Windows-1252";
break;
break; // Western languages
case "WINDOWS-1253":
result = "Windows-1253";
break;
break; // Greek
case "WINDOWS-1254":
result = "Windows-1254";
break;
break; // Turkish
case "WINDOWS-1255":
result = "Windows-1255";
break;
break; // Hebrew
case "WINDOWS-1256":
result = "Windows-1256";
break;
break; // Arabic
case "WINDOWS-1257":
result = "Windows-1257";
break;
break; // Baltic languages
case "WINDOWS-1258":
result = "Windows-1258";
break;
break; // Vietnamese
case "MAC OS ROMAN":

@@ -245,0 +245,0 @@ result = "Mac OS Roman";

@@ -15,2 +15,3 @@ export * as isoly from "./isoly";

import { TimeSpan } from "./TimeSpan";
export { CallingCode, CountryCode, DateSpan, DateRange, Currency, CurrencyCode, Date, DateTime, Encoding, Language, Locale, TimeRange, TimeSpan, };
import { TimeZone } from "./TimeZone";
export { CallingCode, CountryCode, DateSpan, DateRange, Currency, CurrencyCode, Date, DateTime, Encoding, Language, Locale, TimeRange, TimeSpan, TimeZone, };

@@ -15,3 +15,4 @@ export * as isoly from "./isoly";

import { TimeSpan } from "./TimeSpan";
export { CallingCode, CountryCode, DateSpan, DateRange, Currency, CurrencyCode, Date, DateTime, Encoding, Language, Locale, TimeRange, TimeSpan, };
import { TimeZone } from "./TimeZone";
export { CallingCode, CountryCode, DateSpan, DateRange, Currency, CurrencyCode, Date, DateTime, Encoding, Language, Locale, TimeRange, TimeSpan, TimeZone, };
//# sourceMappingURL=index.js.map

@@ -14,2 +14,3 @@ import { CallingCode } from "./CallingCode";

import { TimeSpan } from "./TimeSpan";
export { CallingCode, CountryCode, DateSpan, DateRange, Currency, CurrencyCode, Date, DateTime, Encoding, Language, Locale, TimeRange, TimeSpan, };
import { TimeZone } from "./TimeZone";
export { CallingCode, CountryCode, DateSpan, DateRange, Currency, CurrencyCode, Date, DateTime, Encoding, Language, Locale, TimeRange, TimeSpan, TimeZone, };

@@ -14,3 +14,4 @@ import { CallingCode } from "./CallingCode";

import { TimeSpan } from "./TimeSpan";
export { CallingCode, CountryCode, DateSpan, DateRange, Currency, CurrencyCode, Date, DateTime, Encoding, Language, Locale, TimeRange, TimeSpan, };
import { TimeZone } from "./TimeZone";
export { CallingCode, CountryCode, DateSpan, DateRange, Currency, CurrencyCode, Date, DateTime, Encoding, Language, Locale, TimeRange, TimeSpan, TimeZone, };
//# sourceMappingURL=isoly.js.map

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

export type TimeZone = typeof TimeZone.values[number];
/** IANA format. */
export type TimeZone = "Europe/Stockholm" | "Europe/London" | "UTC" | (string & Record<never, never>);
export declare namespace TimeZone {
const values: string[];
function is(value: TimeZone | any): value is TimeZone;
}
export var TimeZone;
(function (TimeZone) {
TimeZone.values = [
"-12:00",
"-11:00",
"-10:00",
"-09:30",
"-09:00",
"-08:00",
"-07:00",
"-06:00",
"-05:00",
"-04:00",
"-03:30",
"-03:00",
"-02:00",
"-01:00",
"Z",
"+01:00",
"+02:00",
"+03:00",
"+03:30",
"+04:00",
"+04:30",
"+05:00",
"+05:30",
"+05:45",
"+06:00",
"+06:30",
"+07:00",
"+08:00",
"+08:45",
"+09:00",
"+09:30",
"+10:00",
"+10:30",
"+11:00",
"+12:00",
"+12:45",
"+13:00",
"+14:00",
];
function is(value) {
return typeof value == "string" && TimeZone.values.includes(value);
let result;
try {
result = typeof value == "string" && !!new Intl.DateTimeFormat("en-GB", { timeZone: value });
}
catch (error) {
result = false;
}
return result;
}

@@ -46,0 +13,0 @@ TimeZone.is = is;

{
"name": "isoly",
"version": "2.0.16",
"version": "2.0.17",
"description": "Datatypes and functions specified by ISO-standards.",

@@ -5,0 +5,0 @@ "author": "Utily Contributors",

@@ -13,3 +13,3 @@ {

"noImplicitAny": true,
"removeComments": true,
"removeComments": false,
"preserveConstEnums": true,

@@ -28,3 +28,5 @@ "forceConsistentCasingInFileNames": true,

},
"types": ["jest"]
"types": [
"jest"
]
},

@@ -31,0 +33,0 @@ "files": [

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

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