Socket
Socket
Sign inDemoInstall

date-fns

Package Overview
Dependencies
0
Maintainers
1
Versions
200
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.6 to 3.1.0

yearsToDays.d.mts

2

_lib/protectedTokens.d.ts
export declare function isProtectedDayOfYearToken(token: string): boolean;
export declare function isProtectedWeekYearToken(token: string): boolean;
export declare function throwProtectedError(
export declare function warnOrThrowProtectedError(
token: string,

@@ -5,0 +5,0 @@ format: string,

"use strict";
exports.isProtectedDayOfYearToken = isProtectedDayOfYearToken;
exports.isProtectedWeekYearToken = isProtectedWeekYearToken;
exports.throwProtectedError = throwProtectedError;
const protectedDayOfYearTokens = ["D", "DD"];
const protectedWeekYearTokens = ["YY", "YYYY"];
exports.warnOrThrowProtectedError = warnOrThrowProtectedError;
const dayOfYearTokenRE = /^D+$/;
const weekYearTokenRE = /^Y+$/;
const throwTokens = ["D", "DD", "YY", "YYYY"];
function isProtectedDayOfYearToken(token) {
return protectedDayOfYearTokens.indexOf(token) !== -1;
return dayOfYearTokenRE.test(token);
}
function isProtectedWeekYearToken(token) {
return protectedWeekYearTokens.indexOf(token) !== -1;
return weekYearTokenRE.test(token);
}
function throwProtectedError(token, format, input) {
if (token === "YYYY") {
throw new RangeError(
`Use \`yyyy\` instead of \`YYYY\` (in \`${format}\`) for formatting years to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`,
);
} else if (token === "YY") {
throw new RangeError(
`Use \`yy\` instead of \`YY\` (in \`${format}\`) for formatting years to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`,
);
} else if (token === "D") {
throw new RangeError(
`Use \`d\` instead of \`D\` (in \`${format}\`) for formatting days of the month to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`,
);
} else if (token === "DD") {
throw new RangeError(
`Use \`dd\` instead of \`DD\` (in \`${format}\`) for formatting days of the month to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`,
);
}
function warnOrThrowProtectedError(token, format, input) {
const _message = message(token, format, input);
console.warn(_message);
if (throwTokens.includes(token)) throw new RangeError(_message);
}
function message(token, format, input) {
const subject = token[0] === "Y" ? "years" : "days of the month";
return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
}

@@ -13,3 +13,3 @@ import type { Duration } from "./types.js";

* @param date - The date to be changed
* @param duration - The object with years, months, weeks, days, hours, minutes and seconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param duration - The object with years, months, weeks, days, hours, minutes and seconds to be added.
*

@@ -16,0 +16,0 @@ * | Key | Description |

@@ -19,3 +19,3 @@ "use strict";

* @param date - The date to be changed
* @param duration - The object with years, months, weeks, days, hours, minutes and seconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param duration - The object with years, months, weeks, days, hours, minutes and seconds to be added.
*

@@ -22,0 +22,0 @@ * | Key | Description |

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of business days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of business days to be added.
*

@@ -15,0 +15,0 @@ * @returns The new date with the business days added

@@ -20,3 +20,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of business days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of business days to be added.
*

@@ -23,0 +23,0 @@ * @returns The new date with the business days added

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of days to be added.
*

@@ -15,0 +15,0 @@ * @returns The new date with the days added

@@ -17,3 +17,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of days to be added.
*

@@ -20,0 +20,0 @@ * @returns The new date with the days added

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of hours to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of hours to be added.
*

@@ -15,0 +15,0 @@ * @returns The new date with the hours added

@@ -17,3 +17,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of hours to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of hours to be added.
*

@@ -20,0 +20,0 @@ * @returns The new date with the hours added

@@ -14,3 +14,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of ISO week-numbering years to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of ISO week-numbering years to be added.
*

@@ -17,0 +17,0 @@ * @returns The new date with the ISO week-numbering years added

@@ -19,3 +19,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of ISO week-numbering years to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of ISO week-numbering years to be added.
*

@@ -22,0 +22,0 @@ * @returns The new date with the ISO week-numbering years added

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of milliseconds to be added.
*

@@ -15,0 +15,0 @@ * @returns The new date with the milliseconds added

@@ -17,3 +17,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of milliseconds to be added.
*

@@ -20,0 +20,0 @@ * @returns The new date with the milliseconds added

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of minutes to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of minutes to be added.
*

@@ -15,0 +15,0 @@ * @returns The new date with the minutes added

@@ -17,3 +17,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of minutes to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of minutes to be added.
*

@@ -20,0 +20,0 @@ * @returns The new date with the minutes added

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of months to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of months to be added.
*

@@ -15,0 +15,0 @@ * @returns The new date with the months added

@@ -17,3 +17,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of months to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of months to be added.
*

@@ -20,0 +20,0 @@ * @returns The new date with the months added

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of quarters to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of quarters to be added.
*

@@ -15,0 +15,0 @@ * @returns The new date with the quarters added

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of quarters to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of quarters to be added.
*

@@ -19,0 +19,0 @@ * @returns The new date with the quarters added

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of seconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of seconds to be added.
*

@@ -15,0 +15,0 @@ * @returns The new date with the seconds added

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of seconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of seconds to be added.
*

@@ -19,0 +19,0 @@ * @returns The new date with the seconds added

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of weeks to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of weeks to be added.
*

@@ -15,0 +15,0 @@ * @returns The new date with the weeks added

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of weeks to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of weeks to be added.
*

@@ -19,0 +19,0 @@ * @returns The new date with the weeks added

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of years to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of years to be added.
*

@@ -15,0 +15,0 @@ * @returns The new date with the years added

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of years to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of years to be added.
*

@@ -19,0 +19,0 @@ * @returns The new date with the years added

@@ -384,3 +384,7 @@ "use strict";

) {
(0, _index7.throwProtectedError)(substring, formatStr, String(date));
(0, _index7.warnOrThrowProtectedError)(
substring,
formatStr,
String(date),
);
}

@@ -391,3 +395,7 @@ if (

) {
(0, _index7.throwProtectedError)(substring, formatStr, String(date));
(0, _index7.warnOrThrowProtectedError)(
substring,
formatStr,
String(date),
);
}

@@ -394,0 +402,0 @@ return formatter(

@@ -241,4 +241,5 @@ export * from "./add.js";

export * from "./weeksToDays.js";
export * from "./yearsToDays.js";
export * from "./yearsToMonths.js";
export * from "./yearsToQuarters.js";
export type * from "./types.js";

@@ -44,3 +44,3 @@ "use strict";

one: "ungefär en vecka",
other: "ungefär {{count}} vecka",
other: "ungefär {{count}} veckor",
},

@@ -50,3 +50,3 @@

one: "en vecka",
other: "{{count}} vecka",
other: "{{count}} veckor",
},

@@ -53,0 +53,0 @@

@@ -18,3 +18,3 @@ import type { Duration } from "./types.js";

*
* @param duration - The object with years, months, weeks, days, hours, minutes and seconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param duration - The object with years, months, weeks, days, hours, minutes and seconds to be added.
*

@@ -21,0 +21,0 @@ * @returns The milliseconds

@@ -21,3 +21,3 @@ "use strict";

*
* @param duration - The object with years, months, weeks, days, hours, minutes and seconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param duration - The object with years, months, weeks, days, hours, minutes and seconds to be added.
*

@@ -24,0 +24,0 @@ * @returns The milliseconds

@@ -395,3 +395,3 @@ "use strict";

) {
(0, _index6.throwProtectedError)(token, formatStr, dateStr);
(0, _index6.warnOrThrowProtectedError)(token, formatStr, dateStr);
}

@@ -402,3 +402,3 @@ if (

) {
(0, _index6.throwProtectedError)(token, formatStr, dateStr);
(0, _index6.warnOrThrowProtectedError)(token, formatStr, dateStr);
}

@@ -405,0 +405,0 @@

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of business days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of business days to be subtracted.
*

@@ -15,0 +15,0 @@ * @returns The new date with the business days subtracted

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of business days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of business days to be subtracted.
*

@@ -19,0 +19,0 @@ * @returns The new date with the business days subtracted

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of days to be subtracted.
*

@@ -15,0 +15,0 @@ * @returns The new date with the days subtracted

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of days to be subtracted.
*

@@ -19,0 +19,0 @@ * @returns The new date with the days subtracted

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of hours to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of hours to be subtracted.
*

@@ -15,0 +15,0 @@ * @returns The new date with the hours subtracted

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of hours to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of hours to be subtracted.
*

@@ -19,0 +19,0 @@ * @returns The new date with the hours subtracted

@@ -14,3 +14,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of ISO week-numbering years to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of ISO week-numbering years to be subtracted.
*

@@ -17,0 +17,0 @@ * @returns The new date with the ISO week-numbering years subtracted

@@ -18,3 +18,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of ISO week-numbering years to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of ISO week-numbering years to be subtracted.
*

@@ -21,0 +21,0 @@ * @returns The new date with the ISO week-numbering years subtracted

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of milliseconds to be subtracted.
*

@@ -15,0 +15,0 @@ * @returns The new date with the milliseconds subtracted

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of milliseconds to be subtracted.
*

@@ -19,0 +19,0 @@ * @returns The new date with the milliseconds subtracted

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of minutes to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of minutes to be subtracted.
*

@@ -15,0 +15,0 @@ * @returns The new date with the minutes subtracted

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of minutes to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of minutes to be subtracted.
*

@@ -19,0 +19,0 @@ * @returns The new date with the minutes subtracted

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of months to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of months to be subtracted.
*

@@ -15,0 +15,0 @@ * @returns The new date with the months subtracted

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of months to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of months to be subtracted.
*

@@ -19,0 +19,0 @@ * @returns The new date with the months subtracted

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of quarters to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of quarters to be subtracted.
*

@@ -15,0 +15,0 @@ * @returns The new date with the quarters subtracted

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of quarters to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of quarters to be subtracted.
*

@@ -19,0 +19,0 @@ * @returns The new date with the quarters subtracted

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of seconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of seconds to be subtracted.
*

@@ -15,0 +15,0 @@ * @returns The new date with the seconds subtracted

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of seconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of seconds to be subtracted.
*

@@ -19,0 +19,0 @@ * @returns The new date with the seconds subtracted

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of weeks to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of weeks to be subtracted.
*

@@ -15,0 +15,0 @@ * @returns The new date with the weeks subtracted

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of weeks to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of weeks to be subtracted.
*

@@ -19,0 +19,0 @@ * @returns The new date with the weeks subtracted

@@ -12,3 +12,3 @@ /**

* @param date - The date to be changed
* @param amount - The amount of years to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of years to be subtracted.
*

@@ -15,0 +15,0 @@ * @returns The new date with the years subtracted

@@ -16,3 +16,3 @@ "use strict";

* @param date - The date to be changed
* @param amount - The amount of years to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
* @param amount - The amount of years to be subtracted.
*

@@ -19,0 +19,0 @@ * @returns The new date with the years subtracted

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

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

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

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

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 too big to display

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 too big to display

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 too big to display

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

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

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

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc