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
134
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.19 to 2.0.20

5

dist/DateTime.d.ts

@@ -12,2 +12,7 @@ import { Date } from "./Date";

function create(value: globalThis.Date): DateTime;
/**
* Return local time with offset.
* Note: During DST-change, this might be wrong.
*/
function fromLocalDateTime(localDateTime: DateTime, timeZone: TimeZone): string;
function now(): DateTime;

@@ -14,0 +19,0 @@ type Format = Intl.DateTimeFormatOptions;

@@ -79,2 +79,26 @@ import { Date } from "./Date";

DateTime.create = create;
/**
* Return local time with offset.
* Note: During DST-change, this might be wrong.
*/
function fromLocalDateTime(localDateTime, timeZone) {
// Cut off any time-zone-information:
// TODO: Use the information, and just change offset.
localDateTime = localDateTime.replace(/(Z|([+-].{5}))?$/, "");
// Create a Date object with the specified time as UTC
const utcDateTime = new globalThis.Date(`${localDateTime}Z`);
const localDate = new globalThis.Date(utcDateTime.toLocaleString("sv-SE", { timeZone: timeZone }).replace(" ", "T") + "Z");
// Calculate the time difference in minutes
const diffInMinutes = (localDate.getTime() - utcDateTime.getTime()) / 60000;
// Calculate the timezone's offset in hours and minutes
const offsetHours = Math.floor(Math.abs(diffInMinutes) / 60)
.toString()
.padStart(2, "0");
const offsetMinutes = (Math.abs(diffInMinutes) % 60).toString().padStart(2, "0");
// Create the timezone string
const timeZoneString = `${diffInMinutes >= 0 ? "+" : "-"}${offsetHours}:${offsetMinutes}`;
// Return the formatted date string with timezone information
return `${localDateTime}${timeZoneString}`;
}
DateTime.fromLocalDateTime = fromLocalDateTime;
function now() {

@@ -81,0 +105,0 @@ return create(new globalThis.Date());

2

dist/TimeZone.d.ts

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

/** IANA format. */
/** IANA format. Takes any time zone Stockholm, London and UTC is only examples. */
export type TimeZone = "Europe/Stockholm" | "Europe/London" | "UTC" | (string & Record<never, never>);

@@ -3,0 +3,0 @@ export declare namespace TimeZone {

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

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

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