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

@event-calendar/common

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@event-calendar/common - npm Package Compare versions

Comparing version 0.0.1-alpha.5 to 0.0.1-alpha.6

73

index.js

@@ -8,3 +8,3 @@ import { is_function } from 'svelte/internal';

const parts = str.match(/\d+/g);
return new Date(
return new Date(Date.UTC(
Number(parts[0]),

@@ -16,9 +16,19 @@ Number(parts[1]) - 1,

Number(parts[5] || 0)
);
));
}
function createDate(input) {
return input !== undefined
? (input instanceof Date ? cloneDate(input) : fromISOString(input))
: new Date();
if (input !== undefined) {
return input instanceof Date ? cloneDate(input) : fromISOString(input);
}
let now = new Date();
return new Date(Date.UTC(
now.getFullYear(),
now.getMonth(),
now.getDate(),
now.getHours(),
now.getMinutes(),
now.getSeconds()
));
}

@@ -37,3 +47,3 @@

} else if (input instanceof Date) {
input = {hours: input.getHours(), minutes: input.getMinutes(), seconds: input.getSeconds()};
input = {hours: input.getUTCHours(), minutes: input.getUTCMinutes(), seconds: input.getUTCSeconds()};
}

@@ -75,3 +85,3 @@

function setMidnight(date) {
date.setHours(0, 0, 0, 0);
date.setUTCHours(0, 0, 0, 0);

@@ -82,17 +92,7 @@ return date;

function toISOString(date) {
let tzo = -date.getTimezoneOffset(),
dif = tzo >= 0 ? '+' : '-';
return date.getFullYear() +
'-' + _pad(date.getMonth() + 1) +
'-' + _pad(date.getDate()) +
'T' + _pad(date.getHours()) +
':' + _pad(date.getMinutes()) +
':' + _pad(date.getSeconds()) +
dif + _pad(tzo / 60) +
':' + _pad(tzo % 60);
return date.toISOString().substring(0, 19);
}
function formatRange(start, end, intl) {
if (start.getFullYear() !== end.getFullYear()) {
if (start.getUTCFullYear() !== end.getUTCFullYear()) {
return intl.format(start) + ' - ' + intl.format(end);

@@ -102,6 +102,6 @@ }

let diff = [];
if (start.getMonth() !== end.getMonth()) {
if (start.getUTCMonth() !== end.getUTCMonth()) {
diff.push('month');
}
if (start.getDate() !== end.getDate()) {
if (start.getUTCDate() !== end.getUTCDate()) {
diff.push('day');

@@ -139,4 +139,4 @@ }

function nextClosestDay(date, day) {
let diff = day - date.getDay();
date.setDate(date.getDate() + (diff >= 0 ? diff : diff + 7));
let diff = day - date.getUTCDay();
date.setUTCDate(date.getUTCDate() + (diff >= 0 ? diff : diff + 7));
return date;

@@ -146,4 +146,4 @@ }

function prevClosestDay(date, day) {
let diff = day - date.getDay();
date.setDate(date.getDate() + (diff <= 0 ? diff : diff - 7));
let diff = day - date.getUTCDay();
date.setUTCDate(date.getUTCDate() + (diff <= 0 ? diff : diff - 7));
return date;

@@ -157,5 +157,5 @@ }

function _addSubDuration(date, duration, x) {
date.setFullYear(date.getFullYear() + x * duration.years);
let month = date.getMonth() + x * duration.months;
date.setMonth(month);
date.setUTCFullYear(date.getUTCFullYear() + x * duration.years);
let month = date.getUTCMonth() + x * duration.months;
date.setUTCMonth(month);
month %= 12;

@@ -165,7 +165,7 @@ if (month < 0) {

}
while (date.getMonth() !== month) {
while (date.getUTCMonth() !== month) {
subtractDay(date);
}
date.setDate(date.getDate() + x * duration.days);
date.setSeconds(date.getSeconds() + x * duration.seconds);
date.setUTCDate(date.getUTCDate() + x * duration.days);
date.setUTCSeconds(date.getUTCSeconds() + x * duration.seconds);

@@ -176,3 +176,3 @@ return date;

function _addSubDays(date, x) {
date.setDate(date.getDate() + x);
date.setUTCDate(date.getUTCDate() + x);

@@ -182,7 +182,2 @@ return date;

function _pad(num) {
let norm = Math.floor(Math.abs(num));
return (norm < 10 ? '0' : '') + norm;
}
function _commonChunks(str1, substr1, str2, substr2) {

@@ -340,3 +335,3 @@ let i = 0;

? {format: $format}
: new Intl.DateTimeFormat($locale, $format)
: new Intl.DateTimeFormat($locale, {...$format, timeZone: 'UTC'})
);

@@ -350,3 +345,3 @@ }

}
let intl = new Intl.DateTimeFormat($locale, $format);
let intl = new Intl.DateTimeFormat($locale, {...$format, timeZone: 'UTC'});
return {

@@ -353,0 +348,0 @@ format: (start, end) => formatRange(start, end, intl)

{
"name": "@event-calendar/common",
"version": "0.0.1-alpha.5",
"version": "0.0.1-alpha.6",
"type": "module",

@@ -5,0 +5,0 @@ "exports": {

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