timepiece/node_modules/date-fns/constants.mjs

204 lines
3.7 KiB
JavaScript
Raw Normal View History

2024-05-14 14:54:12 +00:00
/**
* @module constants
* @summary Useful constants
* @description
* Collection of useful date constants.
*
* The constants could be imported from `date-fns/constants`:
*
* ```ts
* import { maxTime, minTime } from "./constants/date-fns/constants";
*
* function isAllowedTime(time) {
* return time <= maxTime && time >= minTime;
* }
* ```
*/
/**
* @constant
* @name daysInWeek
* @summary Days in 1 week.
*/
export const daysInWeek = 7;
/**
* @constant
* @name daysInYear
* @summary Days in 1 year.
*
* @description
* How many days in a year.
*
* One years equals 365.2425 days according to the formula:
*
* > Leap year occures every 4 years, except for years that are divisable by 100 and not divisable by 400.
* > 1 mean year = (365+1/4-1/100+1/400) days = 365.2425 days
*/
export const daysInYear = 365.2425;
/**
* @constant
* @name maxTime
* @summary Maximum allowed time.
*
* @example
* import { maxTime } from "./constants/date-fns/constants";
*
* const isValid = 8640000000000001 <= maxTime;
* //=> false
*
* new Date(8640000000000001);
* //=> Invalid Date
*/
export const maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1000;
/**
* @constant
* @name minTime
* @summary Minimum allowed time.
*
* @example
* import { minTime } from "./constants/date-fns/constants";
*
* const isValid = -8640000000000001 >= minTime;
* //=> false
*
* new Date(-8640000000000001)
* //=> Invalid Date
*/
export const minTime = -maxTime;
/**
* @constant
* @name millisecondsInWeek
* @summary Milliseconds in 1 week.
*/
export const millisecondsInWeek = 604800000;
/**
* @constant
* @name millisecondsInDay
* @summary Milliseconds in 1 day.
*/
export const millisecondsInDay = 86400000;
/**
* @constant
* @name millisecondsInMinute
* @summary Milliseconds in 1 minute
*/
export const millisecondsInMinute = 60000;
/**
* @constant
* @name millisecondsInHour
* @summary Milliseconds in 1 hour
*/
export const millisecondsInHour = 3600000;
/**
* @constant
* @name millisecondsInSecond
* @summary Milliseconds in 1 second
*/
export const millisecondsInSecond = 1000;
/**
* @constant
* @name minutesInYear
* @summary Minutes in 1 year.
*/
export const minutesInYear = 525600;
/**
* @constant
* @name minutesInMonth
* @summary Minutes in 1 month.
*/
export const minutesInMonth = 43200;
/**
* @constant
* @name minutesInDay
* @summary Minutes in 1 day.
*/
export const minutesInDay = 1440;
/**
* @constant
* @name minutesInHour
* @summary Minutes in 1 hour.
*/
export const minutesInHour = 60;
/**
* @constant
* @name monthsInQuarter
* @summary Months in 1 quarter.
*/
export const monthsInQuarter = 3;
/**
* @constant
* @name monthsInYear
* @summary Months in 1 year.
*/
export const monthsInYear = 12;
/**
* @constant
* @name quartersInYear
* @summary Quarters in 1 year
*/
export const quartersInYear = 4;
/**
* @constant
* @name secondsInHour
* @summary Seconds in 1 hour.
*/
export const secondsInHour = 3600;
/**
* @constant
* @name secondsInMinute
* @summary Seconds in 1 minute.
*/
export const secondsInMinute = 60;
/**
* @constant
* @name secondsInDay
* @summary Seconds in 1 day.
*/
export const secondsInDay = secondsInHour * 24;
/**
* @constant
* @name secondsInWeek
* @summary Seconds in 1 week.
*/
export const secondsInWeek = secondsInDay * 7;
/**
* @constant
* @name secondsInYear
* @summary Seconds in 1 year.
*/
export const secondsInYear = secondsInDay * daysInYear;
/**
* @constant
* @name secondsInMonth
* @summary Seconds in 1 month
*/
export const secondsInMonth = secondsInYear / 12;
/**
* @constant
* @name secondsInQuarter
* @summary Seconds in 1 quarter.
*/
export const secondsInQuarter = secondsInMonth * 3;