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

@internationalized/date

Package Overview
Dependencies
Maintainers
2
Versions
691
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@internationalized/date - npm Package Compare versions

Comparing version 3.0.0-nightly.3213 to 3.0.0-nightly.3216

3

dist/types.d.ts

@@ -268,2 +268,3 @@ /** An interface that is compatible with any object with date fields. */

constructor(year: number, month: number, day: number);
constructor(era: string, year: number, month: number, day: number);
constructor(calendar: Calendar, year: number, month: number, day: number);

@@ -347,2 +348,3 @@ constructor(calendar: Calendar, era: string, year: number, month: number, day: number);

constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);
constructor(era: string, year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);
constructor(calendar: Calendar, year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);

@@ -400,2 +402,3 @@ constructor(calendar: Calendar, era: string, year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);

constructor(year: number, month: number, day: number, timeZone: string, offset: number, hour?: number, minute?: number, second?: number, millisecond?: number);
constructor(era: string, year: number, month: number, day: number, timeZone: string, offset: number, hour?: number, minute?: number, second?: number, millisecond?: number);
constructor(calendar: Calendar, year: number, month: number, day: number, timeZone: string, offset: number, hour?: number, minute?: number, second?: number, millisecond?: number);

@@ -402,0 +405,0 @@ constructor(calendar: Calendar, era: string, year: number, month: number, day: number, timeZone: string, offset: number, hour?: number, minute?: number, second?: number, millisecond?: number);

4

package.json
{
"name": "@internationalized/date",
"version": "3.0.0-nightly.3213+3fcbe2a0d",
"version": "3.0.0-nightly.3216+1d6bdd52c",
"description": "Internationalized calendar, date, and time manipulation utilities",

@@ -25,3 +25,3 @@ "license": "Apache-2.0",

},
"gitHead": "3fcbe2a0d6fd0d1efe606f643beb3fa65c503830"
"gitHead": "1d6bdd52c9d7a5cbfab84595281494f27e3af90b"
}

@@ -62,2 +62,3 @@ /*

constructor(year: number, month: number, day: number);
constructor(era: string, year: number, month: number, day: number);
constructor(calendar: Calendar, year: number, month: number, day: number);

@@ -217,2 +218,3 @@ constructor(calendar: Calendar, era: string, year: number, month: number, day: number);

constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);
constructor(era: string, year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);
constructor(calendar: Calendar, year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);

@@ -328,2 +330,3 @@ constructor(calendar: Calendar, era: string, year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);

constructor(year: number, month: number, day: number, timeZone: string, offset: number, hour?: number, minute?: number, second?: number, millisecond?: number);
constructor(era: string, year: number, month: number, day: number, timeZone: string, offset: number, hour?: number, minute?: number, second?: number, millisecond?: number);
constructor(calendar: Calendar, year: number, month: number, day: number, timeZone: string, offset: number, hour?: number, minute?: number, second?: number, millisecond?: number);

@@ -330,0 +333,0 @@ constructor(calendar: Calendar, era: string, year: number, month: number, day: number, timeZone: string, offset: number, hour?: number, minute?: number, second?: number, millisecond?: number);

@@ -18,4 +18,3 @@ /*

import {CalendarDate} from '../CalendarDate';
import {GregorianCalendar} from './GregorianCalendar';
import {Mutable} from '../utils';
import {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';

@@ -33,5 +32,10 @@ const BUDDHIST_ERA_START = -543;

fromJulianDay(jd: number): CalendarDate {
let date = super.fromJulianDay(jd) as Mutable<CalendarDate>;
date.year -= BUDDHIST_ERA_START;
return date as CalendarDate;
let gregorianDate = super.fromJulianDay(jd);
let year = getExtendedYear(gregorianDate.era, gregorianDate.year);
return new CalendarDate(
this,
year - BUDDHIST_ERA_START,
gregorianDate.month,
gregorianDate.day
);
}

@@ -53,4 +57,6 @@

function toGregorian(date: AnyCalendarDate) {
let [era, year] = fromExtendedYear(date.year + BUDDHIST_ERA_START);
return new CalendarDate(
date.year + BUDDHIST_ERA_START,
era,
year,
date.month,

@@ -57,0 +63,0 @@ date.day

@@ -21,3 +21,5 @@ /*

const EPOCH = 1721426; // 001/01/03 Julian C.E.
export function gregorianToJulianDay(year: number, month: number, day: number): number {
export function gregorianToJulianDay(era: string, year: number, month: number, day: number): number {
year = getExtendedYear(era, year);
let y1 = year - 1;

@@ -46,2 +48,16 @@ let monthOffset = -2;

export function getExtendedYear(era: string, year: number): number {
return era === 'BC' ? 1 - year : year;
}
export function fromExtendedYear(year: number): [string, number] {
let era = 'AD';
if (year <= 0) {
era = 'BC';
year = 1 - year;
}
return [era, year];
}
const daysInMonth = {

@@ -70,6 +86,7 @@ standard: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],

let year = quadricent * 400 + cent * 100 + quad * 4 + yindex + (cent !== 4 && yindex !== 4 ? 1 : 0);
let yearDay = jd0 - gregorianToJulianDay(year, 1, 1);
let extendedYear = quadricent * 400 + cent * 100 + quad * 4 + yindex + (cent !== 4 && yindex !== 4 ? 1 : 0);
let [era, year] = fromExtendedYear(extendedYear);
let yearDay = jd0 - gregorianToJulianDay(era, year, 1, 1);
let leapAdj = 2;
if (jd0 < gregorianToJulianDay(year, 3, 1)) {
if (jd0 < gregorianToJulianDay(era, year, 3, 1)) {
leapAdj = 0;

@@ -80,9 +97,9 @@ } else if (isLeapYear(year)) {

let month = Math.floor(((yearDay + leapAdj) * 12 + 373) / 367);
let day = jd0 - gregorianToJulianDay(year, month, 1) + 1;
let day = jd0 - gregorianToJulianDay(era, year, month, 1) + 1;
return new CalendarDate(this, year, month, day);
return new CalendarDate(era, year, month, day);
}
toJulianDay(date: AnyCalendarDate): number {
return gregorianToJulianDay(date.year, date.month, date.day);
return gregorianToJulianDay(date.era, date.year, date.month, date.day);
}

@@ -89,0 +106,0 @@

@@ -5,3 +5,2 @@ /*

* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*

@@ -19,4 +18,3 @@ * Unless required by applicable law or agreed to in writing, software distributed under

import {CalendarDate} from '../CalendarDate';
import {GregorianCalendar, gregorianToJulianDay, isLeapYear} from './GregorianCalendar';
import {Mutable} from '../utils';
import {fromExtendedYear, GregorianCalendar, gregorianToJulianDay, isLeapYear} from './GregorianCalendar';

@@ -39,3 +37,3 @@ // Starts in 78 AD,

// Gregorian date for Julian day
let date = super.fromJulianDay(jd) as Mutable<CalendarDate>;
let date = super.fromJulianDay(jd);

@@ -46,3 +44,3 @@ // Year in Saka era

// Day number in Gregorian year (starting from 0)
let yDay = jd - gregorianToJulianDay(date.year, 1, 1);
let yDay = jd - gregorianToJulianDay(date.era, date.year, 1, 1);

@@ -84,3 +82,4 @@ let leapMonth: number;

toJulianDay(date: AnyCalendarDate) {
let year = date.year + INDIAN_ERA_START;
let extendedYear = date.year + INDIAN_ERA_START;
let [era, year] = fromExtendedYear(extendedYear);

@@ -91,6 +90,6 @@ let leapMonth: number;

leapMonth = 31;
jd = gregorianToJulianDay(year, 3, 21);
jd = gregorianToJulianDay(era, year, 3, 21);
} else {
leapMonth = 30;
jd = gregorianToJulianDay(year, 3, 22);
jd = gregorianToJulianDay(era, year, 3, 22);
}

@@ -97,0 +96,0 @@

@@ -76,9 +76,12 @@ /*

fromJulianDay(jd: number): CalendarDate {
let date = super.fromJulianDay(jd) as Mutable<CalendarDate>;
let date = super.fromJulianDay(jd);
let era = findEraFromGregorianDate(date);
let era = findEraFromGregorianDate(date);
date.era = ERA_NAMES[era];
date.year -= ERA_ADDENDS[era];
this.constrainDate(date);
return date as CalendarDate;
return new CalendarDate(
this,
ERA_NAMES[era],
date.year - ERA_ADDENDS[era],
date.month,
date.day
);
}

@@ -85,0 +88,0 @@

@@ -18,3 +18,3 @@ /*

import {CalendarDate} from '../CalendarDate';
import {GregorianCalendar} from './GregorianCalendar';
import {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';
import {Mutable} from '../utils';

@@ -30,10 +30,8 @@

function gregorianToTaiwan(year: number, date: Mutable<AnyCalendarDate>) {
function gregorianToTaiwan(year: number): [string, number] {
let y = year - TAIWAN_ERA_START;
if (y > 0) {
date.era = 'minguo';
date.year = y;
return ['minguo', y];
} else {
date.era = 'before_minguo';
date.year = 1 - y;
return ['before_minguo', 1 - y];
}

@@ -51,5 +49,6 @@ }

fromJulianDay(jd: number): CalendarDate {
let date: Mutable<CalendarDate> = super.fromJulianDay(jd);
gregorianToTaiwan(date.year, date);
return date as CalendarDate;
let date = super.fromJulianDay(jd);
let extendedYear = getExtendedYear(date.era, date.year);
let [era, year] = gregorianToTaiwan(extendedYear);
return new CalendarDate(this, era, year, date.month, date.day);
}

@@ -66,3 +65,5 @@

balanceDate(date: Mutable<AnyCalendarDate>) {
gregorianToTaiwan(gregorianYear(date), date);
let [era, year] = gregorianToTaiwan(gregorianYear(date));
date.era = era;
date.year = year;
}

@@ -80,4 +81,6 @@

function toGregorian(date: AnyCalendarDate) {
let [era, year] = fromExtendedYear(gregorianYear(date));
return new CalendarDate(
gregorianYear(date),
era,
year,
date.month,

@@ -84,0 +87,0 @@ date.day

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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