@bemoje/date 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @bemoje/date v0.0.6
2
+ * @bemoje/date v0.0.8
3
3
  * (c) Benjamin Møller Jensen
4
4
  * Released under the MIT License.
5
- */"use strict";function isValidDate(year,month,day,hour,minute,second,millisecond){year=year?+year:0,month=month?+month:0,day=day?+day:0,hour=hour?+hour:0,minute=minute?+minute:0,second=second?+second:0,millisecond=millisecond?+millisecond:0;const d=new Date(year,month-1,day,hour,minute,second,millisecond);return d.getFullYear()===year&&d.getMonth()+1===month&&d.getDate()===day&&d.getHours()===hour&&d.getMinutes()===minute&&d.getSeconds()===second&&d.getMilliseconds()===millisecond}function assertValidDate(year,month,day,hour,minute,second,millisecond){if(!isValidDate(year,month,day,hour,minute,second,millisecond))throw new Error(`Expected valid date. Got: ${JSON.stringify({year,month,day,hour,minute,second,millisecond})}.`)}function isValidDateMonth(month){return Number.isInteger(month)&&1<=month&&12>=month}function assertValidDateMonth(month){if(!isValidDateMonth(month))throw new Error(`Invalid month: ${month}.`)}function isValidDateYear(year){return Number.isInteger(year)&&0<=year}function assertValidDateYear(year){if(!isValidDateYear(year))throw new Error(`Invalid year: ${year}.`)}function isLeapYear(year){return assertValidDateYear(year),0==year%4&&0!=year%100||0==year%400}function numDaysInMonth(month,year){assertValidDateMonth(month);return 2===month&&year!==void 0&&isLeapYear(year)?29:[0,31,28,31,30,31,30,31,31,30,31,30,31][month]}function isValidDateDay(day,month,year){return!!Number.isInteger(day)&&!!Number.isInteger(month)&&(!year||Number.isInteger(year))&&!(1>day)&&!(day>numDaysInMonth(month,year))}function assertValidDateDay(day,month,year){if(!isValidDateDay(day,month,year))throw new Error(`Invalid day of the month: ${day}.`)}const MS_IN_DAY=86400000,MS_IN_HOUR=3600000,MS_IN_MINUTE=60000,MS_IN_MONTH=2628000000,MS_IN_SECOND=1e3,MS_IN_WEEK=604800000,MS_IN_YEAR=31536000000;function dateDaysAgo(days){const date=new Date;return date.setDate(date.getDate()-days),date}function dateWeekDayName(date){return names[date.getDay()]}const names=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function msSinceDate(date){if("number"==typeof date){if(!Number.isInteger(date))throw new Error("Expected date to be a Date or an integer. Got: "+date);date=new Date(date)}return Date.now()-date.getTime()}function daysSinceDate(date){return msSinceDate(date)/MS_IN_DAY}function getCentury(year){return assertValidDateYear(year),Math.floor(year/100)+1}function getCurrentYear(){return new Date().getUTCFullYear()}function hoursSinceDate(date){return msSinceDate(date)/MS_IN_HOUR}function isoDateTimestamp(date=new Date){return date.toISOString().replace(/\D/g,"")}function isoDateTimestampForFilename(date=new Date){return date.toISOString().replace(/[-:T.]/g,"-").replace("Z","")}function minutesSinceDate(date){return msSinceDate(date)/MS_IN_MINUTE}function monthsSinceDate(date){return msSinceDate(date)/MS_IN_MONTH}function prettyIsoDateString(iso,dateTimeSeparator=" ",precision="millisecond"){return iso.substring(0,map[precision]).replace(/T/,dateTimeSeparator).replace(/-|:/g,".")}const map={year:4,month:7,day:10,hour:13,minute:16,second:19,millisecond:23};function secondsSinceDate(date){return msSinceDate(date)/MS_IN_SECOND}function weeksSinceDate(date){return msSinceDate(date)/MS_IN_WEEK}function yearsSinceDate(date){return msSinceDate(date)/MS_IN_YEAR}exports.MS_IN_DAY=86400000,exports.MS_IN_HOUR=MS_IN_HOUR,exports.MS_IN_MINUTE=MS_IN_MINUTE,exports.MS_IN_MONTH=MS_IN_MONTH,exports.MS_IN_SECOND=MS_IN_SECOND,exports.MS_IN_WEEK=MS_IN_WEEK,exports.MS_IN_YEAR=MS_IN_YEAR,exports.assertValidDate=assertValidDate,exports.assertValidDateDay=assertValidDateDay,exports.assertValidDateMonth=assertValidDateMonth,exports.assertValidDateYear=assertValidDateYear,exports.dateDaysAgo=dateDaysAgo,exports.dateWeekDayName=dateWeekDayName,exports.daysSinceDate=daysSinceDate,exports.getCentury=getCentury,exports.getCurrentYear=getCurrentYear,exports.hoursSinceDate=hoursSinceDate,exports.isLeapYear=isLeapYear,exports.isValidDate=isValidDate,exports.isValidDateDay=isValidDateDay,exports.isValidDateMonth=isValidDateMonth,exports.isValidDateYear=isValidDateYear,exports.isoDateTimestamp=isoDateTimestamp,exports.isoDateTimestampForFilename=isoDateTimestampForFilename,exports.minutesSinceDate=minutesSinceDate,exports.monthsSinceDate=monthsSinceDate,exports.msSinceDate=msSinceDate,exports.numDaysInMonth=numDaysInMonth,exports.prettyIsoDateString=prettyIsoDateString,exports.secondsSinceDate=secondsSinceDate,exports.weeksSinceDate=weeksSinceDate,exports.yearsSinceDate=yearsSinceDate;
5
+ */"use strict";function isValidDate(year,month,day,hour,minute,second,millisecond){year=year?+year:0,month=month?+month:0,day=day?+day:0,hour=hour?+hour:0,minute=minute?+minute:0,second=second?+second:0,millisecond=millisecond?+millisecond:0;const d=new Date(year,month-1,day,hour,minute,second,millisecond);return d.getFullYear()===year&&d.getMonth()+1===month&&d.getDate()===day&&d.getHours()===hour&&d.getMinutes()===minute&&d.getSeconds()===second&&d.getMilliseconds()===millisecond}function assertValidDate(year,month,day,hour,minute,second,millisecond){if(!isValidDate(year,month,day,hour,minute,second,millisecond))throw new Error(`Expected valid date. Got: ${JSON.stringify({year,month,day,hour,minute,second,millisecond})}.`)}function isValidDateMonth(month){return Number.isInteger(month)&&1<=month&&12>=month}function assertValidDateMonth(month){if(!isValidDateMonth(month))throw new Error(`Invalid month: ${month}.`)}function isValidDateYear(year){return Number.isInteger(year)&&0<=year}function assertValidDateYear(year){if(!isValidDateYear(year))throw new Error(`Invalid year: ${year}.`)}function isLeapYear(year){return assertValidDateYear(year),0==year%4&&0!=year%100||0==year%400}function numDaysInMonth(month,year){assertValidDateMonth(month);return 2===month&&year!==void 0&&isLeapYear(year)?29:[0,31,28,31,30,31,30,31,31,30,31,30,31][month]}function isValidDateDay(day,month,year){return!!Number.isInteger(day)&&!!Number.isInteger(month)&&(!year||Number.isInteger(year))&&!(1>day)&&!(day>numDaysInMonth(month,year))}function assertValidDateDay(day,month,year){if(!isValidDateDay(day,month,year))throw new Error(`Invalid day of the month: ${day}.`)}const MS_IN_DAY=86400000,MS_IN_HOUR=3600000,MS_IN_MINUTE=60000,MS_IN_MONTH=2628000000,MS_IN_SECOND=1e3,MS_IN_WEEK=604800000,MS_IN_YEAR=31536000000;function dateDaysAgo(days){const date=new Date;return date.setDate(date.getDate()-days),date}function dateWeekDayName(date){return names[date.getDay()]}const names=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function msSinceDate(date){if("number"==typeof date){if(!Number.isInteger(date))throw new Error("Expected date to be a Date or an integer. Got: "+date);date=new Date(date)}return Date.now()-date.getTime()}function daysSinceDate(date){return msSinceDate(date)/MS_IN_DAY}function getCentury(year){return assertValidDateYear(year),Math.floor(year/100)+1}function getCurrentYear(){return new Date().getUTCFullYear()}function hoursSinceDate(date){return msSinceDate(date)/MS_IN_HOUR}function isoDateTimestamp(date=new Date){return date.toISOString().replace(/\D/g,"")}function isoDateTimestampForFilename(date=new Date){return date.toISOString().replace(/[-:T.]/g,"-").replace("Z","")}function minutesSinceDate(date){return msSinceDate(date)/MS_IN_MINUTE}function monthsSinceDate(date){return msSinceDate(date)/MS_IN_MONTH}function prettyIsoDateString(iso,dateTimeSeparator="_",precision="millisecond"){return iso.substring(0,map[precision]).replace(/T/,dateTimeSeparator).replace(/-|:/g,".")}const map={year:4,month:7,day:10,hour:13,minute:16,second:19,millisecond:23};function secondsSinceDate(date){return msSinceDate(date)/MS_IN_SECOND}function weeksSinceDate(date){return msSinceDate(date)/MS_IN_WEEK}function yearsSinceDate(date){return msSinceDate(date)/MS_IN_YEAR}exports.MS_IN_DAY=86400000,exports.MS_IN_HOUR=MS_IN_HOUR,exports.MS_IN_MINUTE=MS_IN_MINUTE,exports.MS_IN_MONTH=MS_IN_MONTH,exports.MS_IN_SECOND=MS_IN_SECOND,exports.MS_IN_WEEK=MS_IN_WEEK,exports.MS_IN_YEAR=MS_IN_YEAR,exports.assertValidDate=assertValidDate,exports.assertValidDateDay=assertValidDateDay,exports.assertValidDateMonth=assertValidDateMonth,exports.assertValidDateYear=assertValidDateYear,exports.dateDaysAgo=dateDaysAgo,exports.dateWeekDayName=dateWeekDayName,exports.daysSinceDate=daysSinceDate,exports.getCentury=getCentury,exports.getCurrentYear=getCurrentYear,exports.hoursSinceDate=hoursSinceDate,exports.isLeapYear=isLeapYear,exports.isValidDate=isValidDate,exports.isValidDateDay=isValidDateDay,exports.isValidDateMonth=isValidDateMonth,exports.isValidDateYear=isValidDateYear,exports.isoDateTimestamp=isoDateTimestamp,exports.isoDateTimestampForFilename=isoDateTimestampForFilename,exports.minutesSinceDate=minutesSinceDate,exports.monthsSinceDate=monthsSinceDate,exports.msSinceDate=msSinceDate,exports.numDaysInMonth=numDaysInMonth,exports.prettyIsoDateString=prettyIsoDateString,exports.secondsSinceDate=secondsSinceDate,exports.weeksSinceDate=weeksSinceDate,exports.yearsSinceDate=yearsSinceDate;
6
6
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/lib/isValidDate.ts","../src/lib/assertValidDate.ts","../src/lib/isValidDateMonth.ts","../src/lib/assertValidDateMonth.ts","../src/lib/isValidDateYear.ts","../src/lib/assertValidDateYear.ts","../src/lib/isLeapYear.ts","../src/lib/numDaysInMonth.ts","../src/lib/isValidDateDay.ts","../src/lib/assertValidDateDay.ts","../src/lib/constants/MS_IN_DAY.ts","../src/lib/constants/MS_IN_HOUR.ts","../src/lib/constants/MS_IN_MINUTE.ts","../src/lib/constants/MS_IN_MONTH.ts","../src/lib/constants/MS_IN_SECOND.ts","../src/lib/constants/MS_IN_WEEK.ts","../src/lib/constants/MS_IN_YEAR.ts","../src/lib/dateDaysAgo.ts","../src/lib/dateWeekDayName.ts","../src/lib/msSinceDate.ts","../src/lib/daysSinceDate.ts","../src/lib/getCentury.ts","../src/lib/getCurrentYear.ts","../src/lib/hoursSinceDate.ts","../src/lib/isoDateTimestamp.ts","../src/lib/isoDateTimestampForFilename.ts","../src/lib/minutesSinceDate.ts","../src/lib/monthsSinceDate.ts","../src/lib/prettyIsoDateString.ts","../src/lib/secondsSinceDate.ts","../src/lib/weeksSinceDate.ts","../src/lib/yearsSinceDate.ts"],"sourcesContent":["/**\n * Checks if the provided date and time values form a valid date.\n * @param year The year of the date.\n * @param month The month of the date.\n * @param day The day of the date.\n * @param hour The hour of the time.\n * @param minute The minute of the time.\n * @param second The second of the time.\n * @param millisecond The millisecond of the time.\n * @returns A boolean indicating whether the provided date and time values form a valid date.\n * @example ```ts\n * isValidDate(2021, 12, 31, 23, 59, 59, 999);;\n * //=> true\n * isValidDate('2021', '12', '31', '23', '59', '59', '999');;\n * //=> true\n * isValidDate(2021, 13, 31, 23, 59, 59, 999);;\n * //=> false\n * ```\n */\nexport function isValidDate(\n year?: number | string,\n month?: number | string,\n day?: number | string,\n hour?: number | string,\n minute?: number | string,\n second?: number | string,\n millisecond?: number | string,\n): boolean {\n year = year ? Number(year) : 0\n month = month ? Number(month) : 0\n day = day ? Number(day) : 0\n hour = hour ? Number(hour) : 0\n minute = minute ? Number(minute) : 0\n second = second ? Number(second) : 0\n millisecond = millisecond ? Number(millisecond) : 0\n const d = new Date(year, month - 1, day, hour, minute, second, millisecond)\n return (\n d.getFullYear() === year &&\n d.getMonth() + 1 === month &&\n d.getDate() === day &&\n d.getHours() === hour &&\n d.getMinutes() === minute &&\n d.getSeconds() === second &&\n d.getMilliseconds() === millisecond\n )\n}\n","import { isValidDate } from './isValidDate'\n\n/**\n * Asserts that the provided date parameters form a valid date.\n * @param year The year of the date.\n * @param month The month of the date.\n * @param day The day of the date.\n * @param hour The hour of the date.\n * @param minute The minute of the date.\n * @param second The second of the date.\n * @param millisecond The millisecond of the date.\n * @throws Will throw an error if the date is not valid.\n * @example ```ts\n * assertValidDate(2021, 12, 31, 23, 59, 59, 999);;\n * //=> true\n * assertValidDate(2021, 13, 31, 23, 59, 59, 999);;\n * //=> throws an error\n * ```\n */\nexport function assertValidDate(\n year?: number | string,\n month?: number | string,\n day?: number | string,\n hour?: number | string,\n minute?: number | string,\n second?: number | string,\n millisecond?: number | string,\n): void {\n if (!isValidDate(year, month, day, hour, minute, second, millisecond)) {\n throw new Error(\n `Expected valid date. Got: ${JSON.stringify({\n year,\n month,\n day,\n hour,\n minute,\n second,\n millisecond,\n })}.`,\n )\n }\n}\n","/**\n * Checks if the provided month is a valid month number (1-12).\n * @param month The month number to validate.\n * @returns A boolean indicating whether the month is valid.\n * @example ```ts\n * isValidDateMonth(5);;\n * //=> true\n * isValidDateMonth(13);;\n * //=> false\n * ```\n */\nexport function isValidDateMonth(month: number): boolean {\n return Number.isInteger(month) && month >= 1 && month <= 12\n}\n","import { isValidDateMonth } from './isValidDateMonth'\n\n/**\n * Asserts if the provided month is a valid date month.\n * @param month The month to be validated. Should be a number between 1 and 12.\n * @throws Will throw an error if the month is not a valid date month.\n * @example ```ts\n * assertValidDateMonth(13);;\n * //=> Error: Invalid month: 13.\n * assertValidDateMonth(1);;\n * //=> undefined\n * ```\n */\nexport function assertValidDateMonth(month: number): void {\n if (!isValidDateMonth(month)) throw new Error(`Invalid month: ${month}.`)\n}\n","/**\n * Checks if the provided year is a valid date year.\n * @remarks This function will return true if the year is a positive integer, false otherwise.\n * @param year The year to be checked.\n * @returns A boolean indicating whether the year is valid or not.\n * @example ```ts\n * isValidDateYear(2020); ;\n * //=> true\n * isValidDateYear(-2020);;\n * //=> false\n * isValidDateYear(2020.5);;\n * //=> false\n * ```\n */\nexport function isValidDateYear(year: number): boolean {\n return Number.isInteger(year) && year >= 0\n}\n","import { isValidDateYear } from './isValidDateYear'\n\n/**\n * Asserts that the provided year is a valid date year.\n * @param year The year to be validated\n * @throws Will throw an error if the year is not valid.\n * @example ```ts\n * assertValidDateYear(2020);;\n * //=> undefined\n * assertValidDateYear(10000);;\n * //=> Error: Invalid year: 10000.\n * ```\n * @returns void\n */\nexport function assertValidDateYear(year: number): void {\n if (!isValidDateYear(year)) throw new Error(`Invalid year: ${year}.`)\n}\n","import { assertValidDateYear } from './assertValidDateYear'\n\n/**\n * Checks if a given year is a leap year.\n * A leap year is exactly divisible by 4 except for century years (years ending with 00).\n * The century year is a leap year only if it is perfectly divisible by 400.\n * @param year The year to check. Must be a valid year number.\n * @returns `true` if the year is a leap year, `false` otherwise.\n * @throws Will throw an error if the year is not a valid number.\n * @example ```ts\n * isLeapYear(2000); ;\n * //=> true\n * isLeapYear(2001); ;\n * //=> false\n * ```\n */\nexport function isLeapYear(year: number): boolean {\n assertValidDateYear(year)\n return (0 == year % 4 && 0 != year % 100) || 0 == year % 400\n}\n","import { assertValidDateMonth } from './assertValidDateMonth'\nimport { isLeapYear } from './isLeapYear'\n\n/**\n * Get number of days that there are in a given month of a given year.\n * Note: The number of days in february depends on whether it is leap year. If no year is given, it is assumed that it is not leap year.\n * @param month The month for which the number of days is to be calculated. Should be a number between 1 and 12.\n * @param year The year for which the number of days in the month is to be calculated. Optional.\n * @returns The number of days in the given month for the specified year.\n * @throws Will throw an error if the month is not a valid number between 1 and 12.\n * @example ```ts\n * numDaysInMonth(2, 2020);;\n * //=> 29\n * numDaysInMonth(2);;\n * //=> 28\n * numDaysInMonth(1);;\n * //=> 31\n * ```\n */\nexport function numDaysInMonth(month: number, year?: number): number {\n assertValidDateMonth(month)\n const DAYS_IN_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n return month === 2 && year !== undefined && isLeapYear(year) ? 29 : DAYS_IN_MONTH[month]\n}\n","import { numDaysInMonth } from './numDaysInMonth'\n\n/**\n * Checks if the given day is a valid day of the month.\n * @param day The day of the month. Must be an integer.\n * @param month The month of the year. Must be an integer.\n * @param year The year. Optional parameter. If not provided, the function will not check for leap years.\n * @returns A boolean indicating whether the day is valid for the given month and year.\n * @example ```ts\n * isValidDateDay(31, 1, 2000);\n * //=> true\n * isValidDateDay(31, 2, 2000);\n * //=> false\n * isValidDateDay(29, 2);\n * //=> true\n * ```\n */\nexport function isValidDateDay(day: number, month: number, year?: number): boolean {\n if (!Number.isInteger(day)) return false\n if (!Number.isInteger(month)) return false\n if (year && !Number.isInteger(year)) return false\n if (day < 1) return false\n if (day > numDaysInMonth(month, year)) return false\n return true\n}\n","import { isValidDateDay } from './isValidDateDay'\n\n/**\n * Asserts that the provided day, month, and optional year form a valid date.\n * If the date is not valid, it throws an error.\n * @param day The day of the month. Should be an integer between 1 and 31.\n * @param month The month of the year. Should be an integer between 1 and 12.\n * @param year The year of the date. Optional parameter. If provided, should be a positive integer.\n * @throws Will throw an error if the provided day, month, and optional year do not form a valid date.\n * @example ```ts\n * assertValidDateDay(31, 2, 2020);;\n * //=> Error: Invalid day of the month: 31.\n * assertValidDateDay(29, 2, 2020);;\n * //=> no error\n * ```\n */\nexport function assertValidDateDay(day: number, month: number, year?: number): void {\n if (!isValidDateDay(day, month, year)) throw new Error(`Invalid day of the month: ${day}.`)\n}\n","/**\n * The number of milliseconds in a day.\n */\nexport const MS_IN_DAY = 1000 * 60 * 60 * 24\n","/**\n * The number of milliseconds in an hour.\n */\nexport const MS_IN_HOUR = 1000 * 60 * 60\n","/**\n * The number of milliseconds in a minute.\n */\nexport const MS_IN_MINUTE = 1000 * 60\n","/**\n * The number of milliseconds in a month.\n */\nexport const MS_IN_MONTH = (1000 * 60 * 60 * 24 * 365) / 12\n","/**\n * The number of milliseconds in a second.\n */\nexport const MS_IN_SECOND = 1000\n","/**\n * The number of milliseconds in a week.\n */\nexport const MS_IN_WEEK = 1000 * 60 * 60 * 24 * 7\n","/**\n * The number of milliseconds in a year.\n */\nexport const MS_IN_YEAR = 1000 * 60 * 60 * 24 * 365\n","/**\n * Returns a Date object representing a date that is a certain number of days in the past.\n * @param days The number of days ago for the date to represent.\n * @returns A Date object representing the date that is the specified number of days in the past.\n * @example ```ts\n * dateDaysAgo(5);;\n * //=> result\n * ```\n */\nexport function dateDaysAgo(days: number): Date {\n const date = new Date()\n date.setDate(date.getDate() - days)\n return date\n}\n","export function dateWeekDayName(date: Date) {\r\n return names[date.getDay()]\r\n}\r\n\r\nconst names = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']\r\n","/**\n * Calculates the number of milliseconds that have passed since the provided date.\n * @param date The date from which to calculate the elapsed time.\n * @throws If the provided date is not a Date object or an integer.\n * @returns The number of milliseconds that have passed since the provided date.\n * @example ```ts\n * msSinceDate(new Date('2020-01-01'));;\n * //=> {number of milliseconds since 2020-01-01}\n * ```\n */\nexport function msSinceDate(date: Date | number): number {\n if (typeof date === 'number') {\n if (!Number.isInteger(date)) {\n throw new Error('Expected date to be a Date or an integer. Got: ' + date)\n }\n date = new Date(date)\n }\n return Date.now() - date.getTime()\n}\n","import { MS_IN_DAY } from './constants/MS_IN_DAY'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of days that have passed since the given date.\n * @param date The date from which to calculate the number of days passed.\n * @returns The number of days since the given date.\n * @example ```ts\n * new Date('2020-01-01');;\n * //=> <date object>\n * daysSinceDate(new Date('2020-01-01'));;\n * //=> <number of days since 2020-01-01>\n * ```\n */\nexport function daysSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_DAY\n}\n","import { assertValidDateYear } from './assertValidDateYear'\n\n/**\n * This function takes a year as a parameter and returns the century it belongs to.\n * @param year The year to determine the century for. Must be a valid year number.\n * @returns The century the year belongs to.\n * @throws Will throw an error if the year is not a valid number.\n * @example ```ts\n * getCentury(2000);;\n * //=> 20\n * getCentury(1899);;\n * //=> 19\n * ```\n */\nexport function getCentury(year: number): number {\n assertValidDateYear(year)\n return Math.floor(year / 100) + 1\n}\n","/**\n * Returns the current year as a number.\n * @remarks This function uses the `getUTCFullYear` method of the `Date` object to get the current year.\n * @returns The current year as a number.\n * @example ```ts\n * getCurrentYear();;\n * //=> 2022\n * ```\n */\nexport function getCurrentYear(): number {\n return new Date().getUTCFullYear()\n}\n","import { MS_IN_HOUR } from './constants/MS_IN_HOUR'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of hours that have passed since the given date.\n * @param date The date from which to calculate the number of hours passed.\n * @returns The number of hours that have passed since the given date.\n * @example ```ts\n * new Date('2020-01-01T00:00:00Z');;\n * //=> {date object}\n * hoursSinceDate(new Date('2020-01-01T00:00:00Z'));;\n * //=> {number of hours since January 1, 2020}\n * ```\n */\nexport function hoursSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_HOUR\n}\n","/**\n * Converts a given date to an ISO date timestamp string.\n * If no date is provided, the current date and time will be used.\n * @param - The date to convert. Defaults to the current date and time.\n * @returns The ISO date timestamp string.\n * @example ```ts\n * isoDateTimestamp(new Date('2020-01-01T00:00:00Z'));;\n * //=> \"20200101T000000Z\"\n * ```\n * @example ```ts\n * const timestamp = isoDateTimestamp();\n * console.log(timestamp); // Outputs the current date and time in ISO format, e.g. \"20210520T102030Z\"\n * ```\n */\nexport function isoDateTimestamp(date = new Date()): string {\n return date.toISOString().replace(/\\D/g, '')\n}\n","/**\n * This function takes a date object and returns a string in ISO format suitable for filenames.\n * If no date is provided, it uses the current date and time.\n * @param date The date object to be converted. Defaults to the current date and time.\n * @returns A string in the format \"YYYY-MM-DD-HH-MM-SS-SSS\".\n * @example ```ts\n * isoDateTimestampForFilename(new Date('2022-01-01T00:00:00Z'));;\n * //=> \"2022-01-01-00-00-00-000\"\n * ```\n */\nexport function isoDateTimestampForFilename(date = new Date()): string {\n return date\n .toISOString()\n .replace(/[-:T.]/g, '-')\n .replace('Z', '')\n}\n","import { MS_IN_MINUTE } from './constants/MS_IN_MINUTE'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of minutes that have passed since the given date.\n * @param date The date from which to calculate the number of minutes that have passed.\n * @returns The number of minutes that have passed since the given date.\n * @example ```ts\n * new Date('2020-01-01T00:00:00Z');;\n * //=> {date}\n * minutesSinceDate(new Date('2020-01-01T00:00:00Z'));;\n * //=> {number of minutes since 2020-01-01T00:00:00Z}\n * ```\n */\nexport function minutesSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_MINUTE\n}\n","import { MS_IN_MONTH } from './constants/MS_IN_MONTH'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of months that have passed since the provided date.\n * @param date The date from which to calculate the number of passed months.\n * @returns The number of months that have passed since the provided date.\n * @example ```ts\n * new Date(2020, 0, 1);;\n * //=> {date}\n * monthsSinceDate(new Date(2020, 0, 1));;\n * //=> {number of months since January 1, 2020}\n * ```\n */\nexport function monthsSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_MONTH\n}\n","export function prettyIsoDateString(\r\n iso: string,\r\n dateTimeSeparator = ' ',\r\n precision: 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond' = 'millisecond',\r\n) {\r\n return iso.substring(0, map[precision]).replace(/T/, dateTimeSeparator).replace(/-|:/g, '.')\r\n}\r\n\r\nconst map = {\r\n year: 4,\r\n month: 7,\r\n day: 10,\r\n hour: 13,\r\n minute: 16,\r\n second: 19,\r\n millisecond: 23,\r\n}\r\n\r\n// const s = '2020-02-03T14:01:04.437Z'\r\n// console.log(prettyIsoDateString(s, ' ', 'year'))\r\n// console.log(prettyIsoDateString(s, ' ', 'month'))\r\n// console.log(prettyIsoDateString(s, ' ', 'day'))\r\n// console.log(prettyIsoDateString(s, ' ', 'hour'))\r\n// console.log(prettyIsoDateString(s, ' ', 'minute'))\r\n// console.log(prettyIsoDateString(s, ' ', 'second'))\r\n// console.log(prettyIsoDateString(s, ' ', 'millisecond'))\r\n","import { MS_IN_SECOND } from './constants/MS_IN_SECOND'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Returns the number of seconds that have passed since the given date.\n * @param date The date from which to calculate the number of seconds.\n * @returns The number of seconds since the given date.\n * @example ```ts\n * secondsSinceDate(new Date('2020-01-01'));;\n * //=> {number of seconds since 2020-01-01}\n * ```\n */\nexport function secondsSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_SECOND\n}\n","import { MS_IN_WEEK } from './constants/MS_IN_WEEK'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of weeks that have passed since the provided date.\n * @param date The date from which to calculate the number of weeks passed.\n * @returns The number of weeks since the provided date.\n * @example ```ts\n * weeksSinceDate(new Date('2020-01-01'));;\n * //=> {number of weeks since '2020-01-01'}\n * ```\n */\nexport function weeksSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_WEEK\n}\n","import { MS_IN_YEAR } from './constants/MS_IN_YEAR'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of years that have passed since the provided date.\n * @param date The date from which to calculate the number of years passed.\n * @returns The number of years that have passed since the provided date.\n * @example ```ts\n * yearsSinceDate(new Date('2000-01-01'));;\n * //=> {number of years since '2000-01-01'}\n * ```\n */\nexport function yearsSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_YEAR\n}\n"],"names":["isValidDate","year","month","day","hour","minute","second","millisecond","d","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","getMilliseconds","assertValidDate","Error","JSON","stringify","isValidDateMonth","Number","isInteger","assertValidDateMonth","isValidDateYear","assertValidDateYear","isLeapYear","numDaysInMonth","isValidDateDay","assertValidDateDay","MS_IN_DAY","MS_IN_HOUR","MS_IN_MINUTE","MS_IN_MONTH","MS_IN_SECOND","MS_IN_WEEK","MS_IN_YEAR","dateDaysAgo","days","date","setDate","dateWeekDayName","names","getDay","msSinceDate","now","getTime","daysSinceDate","getCentury","Math","floor","getCurrentYear","getUTCFullYear","hoursSinceDate","isoDateTimestamp","toISOString","replace","isoDateTimestampForFilename","minutesSinceDate","monthsSinceDate","prettyIsoDateString","iso","dateTimeSeparator","precision","substring","map","secondsSinceDate","weeksSinceDate","yearsSinceDate"],"mappings":";;;;gBAmBgB,QAAA,CAAAA,WAAWA,CACzBC,I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AAC,CACvBA,OAAO,CAAC,GAAG,CAAE,EAAE,CACpB,CCDM,QAAU,CAAAE,gBAAgBA,CAACnB,IAAmB,CAAA,CAClD,MAAO,CAAAK,WAAW,CAACL,IAAI,CAAC,CAAGP,YAC7B,CCFM,QAAU,CAAA2B,eAAeA,CAACpB,IAAmB,CAAA,CACjD,MAAO,CAAAK,WAAW,CAACL,IAAI,CAAC,CAAGN,WAC7B,CChBM,QAAU,CAAA2B,mBAAmBA,CACjCC,GAAW,CACXC,iBAAiB,CAAG,GAAG,CACvBC,SAAA,CAAqF,aAAa,CAAA,CAElG,MAAO,CAAAF,GAAG,CAACG,SAAS,CAAC,CAAC,CAAEC,GAAG,CAACF,SAAS,CAAC,CAAC,CAACP,OAAO,CAAC,GAAG,CAAEM,iBAAiB,CAAC,CAACN,OAAO,CAAC,MAAM,CAAE,GAAG,CAC7F,CAEA,KAAM,CAAAS,GAAG,CAAG,CACVjE,IAAI,CAAE,CAAC,CACPC,KAAK,CAAE,CAAC,CACRC,GAAG,CAAE,EAAE,CACPC,IAAI,CAAE,EAAE,CACRC,MAAM,CAAE,EAAE,CACVC,MAAM,CAAE,EAAE,CACVC,WAAW,CAAE,GACd,CCJK,QAAU,CAAA4D,gBAAgBA,CAAC3B,IAAmB,CAAA,CAClD,MAAO,CAAAK,WAAW,CAACL,IAAI,CAAC,CAAGL,YAC7B,CCFM,QAAU,CAAAiC,cAAcA,CAAC5B,IAAmB,CAAA,CAChD,MAAO,CAAAK,WAAW,CAACL,IAAI,CAAC,CAAGJ,UAC7B,CCFM,QAAU,CAAAiC,cAAcA,CAAC7B,IAAmB,CAAA,CAChD,MAAO,CAAAK,WAAW,CAACL,IAAI,CAAC,CAAGH,UAC7B"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/lib/isValidDate.ts","../src/lib/assertValidDate.ts","../src/lib/isValidDateMonth.ts","../src/lib/assertValidDateMonth.ts","../src/lib/isValidDateYear.ts","../src/lib/assertValidDateYear.ts","../src/lib/isLeapYear.ts","../src/lib/numDaysInMonth.ts","../src/lib/isValidDateDay.ts","../src/lib/assertValidDateDay.ts","../src/lib/constants/MS_IN_DAY.ts","../src/lib/constants/MS_IN_HOUR.ts","../src/lib/constants/MS_IN_MINUTE.ts","../src/lib/constants/MS_IN_MONTH.ts","../src/lib/constants/MS_IN_SECOND.ts","../src/lib/constants/MS_IN_WEEK.ts","../src/lib/constants/MS_IN_YEAR.ts","../src/lib/dateDaysAgo.ts","../src/lib/dateWeekDayName.ts","../src/lib/msSinceDate.ts","../src/lib/daysSinceDate.ts","../src/lib/getCentury.ts","../src/lib/getCurrentYear.ts","../src/lib/hoursSinceDate.ts","../src/lib/isoDateTimestamp.ts","../src/lib/isoDateTimestampForFilename.ts","../src/lib/minutesSinceDate.ts","../src/lib/monthsSinceDate.ts","../src/lib/prettyIsoDateString.ts","../src/lib/secondsSinceDate.ts","../src/lib/weeksSinceDate.ts","../src/lib/yearsSinceDate.ts"],"sourcesContent":["/**\n * Checks if the provided date and time values form a valid date.\n * @param year The year of the date.\n * @param month The month of the date.\n * @param day The day of the date.\n * @param hour The hour of the time.\n * @param minute The minute of the time.\n * @param second The second of the time.\n * @param millisecond The millisecond of the time.\n * @returns A boolean indicating whether the provided date and time values form a valid date.\n * @example ```ts\n * isValidDate(2021, 12, 31, 23, 59, 59, 999);;\n * //=> true\n * isValidDate('2021', '12', '31', '23', '59', '59', '999');;\n * //=> true\n * isValidDate(2021, 13, 31, 23, 59, 59, 999);;\n * //=> false\n * ```\n */\nexport function isValidDate(\n year?: number | string,\n month?: number | string,\n day?: number | string,\n hour?: number | string,\n minute?: number | string,\n second?: number | string,\n millisecond?: number | string,\n): boolean {\n year = year ? Number(year) : 0\n month = month ? Number(month) : 0\n day = day ? Number(day) : 0\n hour = hour ? Number(hour) : 0\n minute = minute ? Number(minute) : 0\n second = second ? Number(second) : 0\n millisecond = millisecond ? Number(millisecond) : 0\n const d = new Date(year, month - 1, day, hour, minute, second, millisecond)\n return (\n d.getFullYear() === year &&\n d.getMonth() + 1 === month &&\n d.getDate() === day &&\n d.getHours() === hour &&\n d.getMinutes() === minute &&\n d.getSeconds() === second &&\n d.getMilliseconds() === millisecond\n )\n}\n","import { isValidDate } from './isValidDate'\n\n/**\n * Asserts that the provided date parameters form a valid date.\n * @param year The year of the date.\n * @param month The month of the date.\n * @param day The day of the date.\n * @param hour The hour of the date.\n * @param minute The minute of the date.\n * @param second The second of the date.\n * @param millisecond The millisecond of the date.\n * @throws Will throw an error if the date is not valid.\n * @example ```ts\n * assertValidDate(2021, 12, 31, 23, 59, 59, 999);;\n * //=> true\n * assertValidDate(2021, 13, 31, 23, 59, 59, 999);;\n * //=> throws an error\n * ```\n */\nexport function assertValidDate(\n year?: number | string,\n month?: number | string,\n day?: number | string,\n hour?: number | string,\n minute?: number | string,\n second?: number | string,\n millisecond?: number | string,\n): void {\n if (!isValidDate(year, month, day, hour, minute, second, millisecond)) {\n throw new Error(\n `Expected valid date. Got: ${JSON.stringify({\n year,\n month,\n day,\n hour,\n minute,\n second,\n millisecond,\n })}.`,\n )\n }\n}\n","/**\n * Checks if the provided month is a valid month number (1-12).\n * @param month The month number to validate.\n * @returns A boolean indicating whether the month is valid.\n * @example ```ts\n * isValidDateMonth(5);;\n * //=> true\n * isValidDateMonth(13);;\n * //=> false\n * ```\n */\nexport function isValidDateMonth(month: number): boolean {\n return Number.isInteger(month) && month >= 1 && month <= 12\n}\n","import { isValidDateMonth } from './isValidDateMonth'\n\n/**\n * Asserts if the provided month is a valid date month.\n * @param month The month to be validated. Should be a number between 1 and 12.\n * @throws Will throw an error if the month is not a valid date month.\n * @example ```ts\n * assertValidDateMonth(13);;\n * //=> Error: Invalid month: 13.\n * assertValidDateMonth(1);;\n * //=> undefined\n * ```\n */\nexport function assertValidDateMonth(month: number): void {\n if (!isValidDateMonth(month)) throw new Error(`Invalid month: ${month}.`)\n}\n","/**\n * Checks if the provided year is a valid date year.\n * @remarks This function will return true if the year is a positive integer, false otherwise.\n * @param year The year to be checked.\n * @returns A boolean indicating whether the year is valid or not.\n * @example ```ts\n * isValidDateYear(2020); ;\n * //=> true\n * isValidDateYear(-2020);;\n * //=> false\n * isValidDateYear(2020.5);;\n * //=> false\n * ```\n */\nexport function isValidDateYear(year: number): boolean {\n return Number.isInteger(year) && year >= 0\n}\n","import { isValidDateYear } from './isValidDateYear'\n\n/**\n * Asserts that the provided year is a valid date year.\n * @param year The year to be validated\n * @throws Will throw an error if the year is not valid.\n * @example ```ts\n * assertValidDateYear(2020);;\n * //=> undefined\n * assertValidDateYear(10000);;\n * //=> Error: Invalid year: 10000.\n * ```\n * @returns void\n */\nexport function assertValidDateYear(year: number): void {\n if (!isValidDateYear(year)) throw new Error(`Invalid year: ${year}.`)\n}\n","import { assertValidDateYear } from './assertValidDateYear'\n\n/**\n * Checks if a given year is a leap year.\n * A leap year is exactly divisible by 4 except for century years (years ending with 00).\n * The century year is a leap year only if it is perfectly divisible by 400.\n * @param year The year to check. Must be a valid year number.\n * @returns `true` if the year is a leap year, `false` otherwise.\n * @throws Will throw an error if the year is not a valid number.\n * @example ```ts\n * isLeapYear(2000); ;\n * //=> true\n * isLeapYear(2001); ;\n * //=> false\n * ```\n */\nexport function isLeapYear(year: number): boolean {\n assertValidDateYear(year)\n return (0 == year % 4 && 0 != year % 100) || 0 == year % 400\n}\n","import { assertValidDateMonth } from './assertValidDateMonth'\nimport { isLeapYear } from './isLeapYear'\n\n/**\n * Get number of days that there are in a given month of a given year.\n * Note: The number of days in february depends on whether it is leap year. If no year is given, it is assumed that it is not leap year.\n * @param month The month for which the number of days is to be calculated. Should be a number between 1 and 12.\n * @param year The year for which the number of days in the month is to be calculated. Optional.\n * @returns The number of days in the given month for the specified year.\n * @throws Will throw an error if the month is not a valid number between 1 and 12.\n * @example ```ts\n * numDaysInMonth(2, 2020);;\n * //=> 29\n * numDaysInMonth(2);;\n * //=> 28\n * numDaysInMonth(1);;\n * //=> 31\n * ```\n */\nexport function numDaysInMonth(month: number, year?: number): number {\n assertValidDateMonth(month)\n const DAYS_IN_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n return month === 2 && year !== undefined && isLeapYear(year) ? 29 : DAYS_IN_MONTH[month]\n}\n","import { numDaysInMonth } from './numDaysInMonth'\n\n/**\n * Checks if the given day is a valid day of the month.\n * @param day The day of the month. Must be an integer.\n * @param month The month of the year. Must be an integer.\n * @param year The year. Optional parameter. If not provided, the function will not check for leap years.\n * @returns A boolean indicating whether the day is valid for the given month and year.\n * @example ```ts\n * isValidDateDay(31, 1, 2000);\n * //=> true\n * isValidDateDay(31, 2, 2000);\n * //=> false\n * isValidDateDay(29, 2);\n * //=> true\n * ```\n */\nexport function isValidDateDay(day: number, month: number, year?: number): boolean {\n if (!Number.isInteger(day)) return false\n if (!Number.isInteger(month)) return false\n if (year && !Number.isInteger(year)) return false\n if (day < 1) return false\n if (day > numDaysInMonth(month, year)) return false\n return true\n}\n","import { isValidDateDay } from './isValidDateDay'\n\n/**\n * Asserts that the provided day, month, and optional year form a valid date.\n * If the date is not valid, it throws an error.\n * @param day The day of the month. Should be an integer between 1 and 31.\n * @param month The month of the year. Should be an integer between 1 and 12.\n * @param year The year of the date. Optional parameter. If provided, should be a positive integer.\n * @throws Will throw an error if the provided day, month, and optional year do not form a valid date.\n * @example ```ts\n * assertValidDateDay(31, 2, 2020);;\n * //=> Error: Invalid day of the month: 31.\n * assertValidDateDay(29, 2, 2020);;\n * //=> no error\n * ```\n */\nexport function assertValidDateDay(day: number, month: number, year?: number): void {\n if (!isValidDateDay(day, month, year)) throw new Error(`Invalid day of the month: ${day}.`)\n}\n","/**\n * The number of milliseconds in a day.\n */\nexport const MS_IN_DAY = 1000 * 60 * 60 * 24\n","/**\n * The number of milliseconds in an hour.\n */\nexport const MS_IN_HOUR = 1000 * 60 * 60\n","/**\n * The number of milliseconds in a minute.\n */\nexport const MS_IN_MINUTE = 1000 * 60\n","/**\n * The number of milliseconds in a month.\n */\nexport const MS_IN_MONTH = (1000 * 60 * 60 * 24 * 365) / 12\n","/**\n * The number of milliseconds in a second.\n */\nexport const MS_IN_SECOND = 1000\n","/**\n * The number of milliseconds in a week.\n */\nexport const MS_IN_WEEK = 1000 * 60 * 60 * 24 * 7\n","/**\n * The number of milliseconds in a year.\n */\nexport const MS_IN_YEAR = 1000 * 60 * 60 * 24 * 365\n","/**\n * Returns a Date object representing a date that is a certain number of days in the past.\n * @param days The number of days ago for the date to represent.\n * @returns A Date object representing the date that is the specified number of days in the past.\n * @example ```ts\n * dateDaysAgo(5);;\n * //=> result\n * ```\n */\nexport function dateDaysAgo(days: number): Date {\n const date = new Date()\n date.setDate(date.getDate() - days)\n return date\n}\n","export function dateWeekDayName(date: Date) {\r\n return names[date.getDay()]\r\n}\r\n\r\nconst names = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']\r\n","/**\n * Calculates the number of milliseconds that have passed since the provided date.\n * @param date The date from which to calculate the elapsed time.\n * @throws If the provided date is not a Date object or an integer.\n * @returns The number of milliseconds that have passed since the provided date.\n * @example ```ts\n * msSinceDate(new Date('2020-01-01'));;\n * //=> {number of milliseconds since 2020-01-01}\n * ```\n */\nexport function msSinceDate(date: Date | number): number {\n if (typeof date === 'number') {\n if (!Number.isInteger(date)) {\n throw new Error('Expected date to be a Date or an integer. Got: ' + date)\n }\n date = new Date(date)\n }\n return Date.now() - date.getTime()\n}\n","import { MS_IN_DAY } from './constants/MS_IN_DAY'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of days that have passed since the given date.\n * @param date The date from which to calculate the number of days passed.\n * @returns The number of days since the given date.\n * @example ```ts\n * new Date('2020-01-01');;\n * //=> <date object>\n * daysSinceDate(new Date('2020-01-01'));;\n * //=> <number of days since 2020-01-01>\n * ```\n */\nexport function daysSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_DAY\n}\n","import { assertValidDateYear } from './assertValidDateYear'\n\n/**\n * This function takes a year as a parameter and returns the century it belongs to.\n * @param year The year to determine the century for. Must be a valid year number.\n * @returns The century the year belongs to.\n * @throws Will throw an error if the year is not a valid number.\n * @example ```ts\n * getCentury(2000);;\n * //=> 20\n * getCentury(1899);;\n * //=> 19\n * ```\n */\nexport function getCentury(year: number): number {\n assertValidDateYear(year)\n return Math.floor(year / 100) + 1\n}\n","/**\n * Returns the current year as a number.\n * @remarks This function uses the `getUTCFullYear` method of the `Date` object to get the current year.\n * @returns The current year as a number.\n * @example ```ts\n * getCurrentYear();;\n * //=> 2022\n * ```\n */\nexport function getCurrentYear(): number {\n return new Date().getUTCFullYear()\n}\n","import { MS_IN_HOUR } from './constants/MS_IN_HOUR'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of hours that have passed since the given date.\n * @param date The date from which to calculate the number of hours passed.\n * @returns The number of hours that have passed since the given date.\n * @example ```ts\n * new Date('2020-01-01T00:00:00Z');;\n * //=> {date object}\n * hoursSinceDate(new Date('2020-01-01T00:00:00Z'));;\n * //=> {number of hours since January 1, 2020}\n * ```\n */\nexport function hoursSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_HOUR\n}\n","/**\n * Converts a given date to an ISO date timestamp string.\n * If no date is provided, the current date and time will be used.\n * @param - The date to convert. Defaults to the current date and time.\n * @returns The ISO date timestamp string.\n * @example ```ts\n * isoDateTimestamp(new Date('2020-01-01T00:00:00Z'));;\n * //=> \"20200101T000000Z\"\n * ```\n * @example ```ts\n * const timestamp = isoDateTimestamp();\n * console.log(timestamp); // Outputs the current date and time in ISO format, e.g. \"20210520T102030Z\"\n * ```\n */\nexport function isoDateTimestamp(date = new Date()): string {\n return date.toISOString().replace(/\\D/g, '')\n}\n","/**\n * This function takes a date object and returns a string in ISO format suitable for filenames.\n * If no date is provided, it uses the current date and time.\n * @param date The date object to be converted. Defaults to the current date and time.\n * @returns A string in the format \"YYYY-MM-DD-HH-MM-SS-SSS\".\n * @example ```ts\n * isoDateTimestampForFilename(new Date('2022-01-01T00:00:00Z'));;\n * //=> \"2022-01-01-00-00-00-000\"\n * ```\n */\nexport function isoDateTimestampForFilename(date = new Date()): string {\n return date\n .toISOString()\n .replace(/[-:T.]/g, '-')\n .replace('Z', '')\n}\n","import { MS_IN_MINUTE } from './constants/MS_IN_MINUTE'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of minutes that have passed since the given date.\n * @param date The date from which to calculate the number of minutes that have passed.\n * @returns The number of minutes that have passed since the given date.\n * @example ```ts\n * new Date('2020-01-01T00:00:00Z');;\n * //=> {date}\n * minutesSinceDate(new Date('2020-01-01T00:00:00Z'));;\n * //=> {number of minutes since 2020-01-01T00:00:00Z}\n * ```\n */\nexport function minutesSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_MINUTE\n}\n","import { MS_IN_MONTH } from './constants/MS_IN_MONTH'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of months that have passed since the provided date.\n * @param date The date from which to calculate the number of passed months.\n * @returns The number of months that have passed since the provided date.\n * @example ```ts\n * new Date(2020, 0, 1);;\n * //=> {date}\n * monthsSinceDate(new Date(2020, 0, 1));;\n * //=> {number of months since January 1, 2020}\n * ```\n */\nexport function monthsSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_MONTH\n}\n","export function prettyIsoDateString(\r\n iso: string,\r\n dateTimeSeparator = '_',\r\n precision: 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond' = 'millisecond',\r\n) {\r\n return iso.substring(0, map[precision]).replace(/T/, dateTimeSeparator).replace(/-|:/g, '.')\r\n}\r\n\r\nconst map = {\r\n year: 4,\r\n month: 7,\r\n day: 10,\r\n hour: 13,\r\n minute: 16,\r\n second: 19,\r\n millisecond: 23,\r\n}\r\n\r\n// const s = '2020-02-03T14:01:04.437Z'\r\n// console.log(prettyIsoDateString(s, '_', 'year'))\r\n// console.log(prettyIsoDateString(s, '_', 'month'))\r\n// console.log(prettyIsoDateString(s, '_', 'day'))\r\n// console.log(prettyIsoDateString(s, '_', 'hour'))\r\n// console.log(prettyIsoDateString(s, '_', 'minute'))\r\n// console.log(prettyIsoDateString(s, '_', 'second'))\r\n// console.log(prettyIsoDateString(s, '_', 'millisecond'))\r\n","import { MS_IN_SECOND } from './constants/MS_IN_SECOND'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Returns the number of seconds that have passed since the given date.\n * @param date The date from which to calculate the number of seconds.\n * @returns The number of seconds since the given date.\n * @example ```ts\n * secondsSinceDate(new Date('2020-01-01'));;\n * //=> {number of seconds since 2020-01-01}\n * ```\n */\nexport function secondsSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_SECOND\n}\n","import { MS_IN_WEEK } from './constants/MS_IN_WEEK'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of weeks that have passed since the provided date.\n * @param date The date from which to calculate the number of weeks passed.\n * @returns The number of weeks since the provided date.\n * @example ```ts\n * weeksSinceDate(new Date('2020-01-01'));;\n * //=> {number of weeks since '2020-01-01'}\n * ```\n */\nexport function weeksSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_WEEK\n}\n","import { MS_IN_YEAR } from './constants/MS_IN_YEAR'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of years that have passed since the provided date.\n * @param date The date from which to calculate the number of years passed.\n * @returns The number of years that have passed since the provided date.\n * @example ```ts\n * yearsSinceDate(new Date('2000-01-01'));;\n * //=> {number of years since '2000-01-01'}\n * ```\n */\nexport function yearsSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_YEAR\n}\n"],"names":["isValidDate","year","month","day","hour","minute","second","millisecond","d","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","getMilliseconds","assertValidDate","Error","JSON","stringify","isValidDateMonth","Number","isInteger","assertValidDateMonth","isValidDateYear","assertValidDateYear","isLeapYear","numDaysInMonth","isValidDateDay","assertValidDateDay","MS_IN_DAY","MS_IN_HOUR","MS_IN_MINUTE","MS_IN_MONTH","MS_IN_SECOND","MS_IN_WEEK","MS_IN_YEAR","dateDaysAgo","days","date","setDate","dateWeekDayName","names","getDay","msSinceDate","now","getTime","daysSinceDate","getCentury","Math","floor","getCurrentYear","getUTCFullYear","hoursSinceDate","isoDateTimestamp","toISOString","replace","isoDateTimestampForFilename","minutesSinceDate","monthsSinceDate","prettyIsoDateString","iso","dateTimeSeparator","precision","substring","map","secondsSinceDate","weeksSinceDate","yearsSinceDate"],"mappings":";;;;gBAmBgB,QAAA,CAAAA,WAAWA,CACzBC,IAAsB,CACtBC,KAAuB,CACvBC,GAAqB,CACrBC,IAAsB,CACtBC,MAAwB,CACxBC,MAAwB,CACxBC,WAA6B,CAAA,CAE7BN,IAAI,CAAGA,IAAI,EAAUA,IAAI,CAAI,CAAC,CAC9BC,KAAK,CAAGA,KAAK,EAAUA,KAAK,CAAI,CAAC,CACjCC,GAAG,CAAGA,GAAG,EAAUA,GAAG,CAAI,CAAC,CAC3BC,IAAI,CAAGA,IAAI,EAAUA,IAAI,CAAI,CAAC,CAC9BC,MAAM,CAAGA,MAAM,EAAUA,MAAM,CAAI,CAAC,CACpCC,MAAM,CAAGA,MAAM,EAAUA,MAAM,CAAI,CAAC,CACpCC,WAAW,CAAGA,WAAW,EAAUA,WAAW,CAAI,CAAC,CACnD,KAAM,CAAAC,CAAC,CAAG,GAAI,CAAAC,IAAI,CAACR,IAAI,CAAEC,KAAK,CAAG,CAAC,CAAEC,GAAG,CAAEC,IAAI,CAAEC,MAAM,CAAEC,MAAM,CAAEC,WAAW,CAAC,CAC3E,MACE,CAAAC,CAAC,CAACE,WAAW,CAAA,CAAE,GAAKT,IAAI,EACxBO,CAAC,CAACG,QAAQ,EAAE,CAAG,CAAC,GAAKT,KAAK,EAC1BM,CAAC,CAACI,OAAO,CAAA,CAAE,GAAKT,GAAG,EACnBK,CAAC,CAACK,QAAQ,CAAA,CAAE,GAAKT,IAAI,EACrBI,CAAC,CAACM,UAAU,CAAA,CAAE,GAAKT,MAAM,EACzB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AAO,CAAAK,WAAW,CAACL,IAAI,CAAC,CAAGJ,UAC7B,CCFM,QAAU,CAAAiC,cAAcA,CAAC7B,IAAmB,CAAA,CAChD,MAAO,CAAAK,WAAW,CAACL,IAAI,CAAC,CAAGH,UAC7B"}
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @bemoje/date v0.0.6
2
+ * @bemoje/date v0.0.8
3
3
  * (c) Benjamin Møller Jensen
4
4
  * Released under the MIT License.
5
- */function isValidDate(year,month,day,hour,minute,second,millisecond){year=year?+year:0,month=month?+month:0,day=day?+day:0,hour=hour?+hour:0,minute=minute?+minute:0,second=second?+second:0,millisecond=millisecond?+millisecond:0;const d=new Date(year,month-1,day,hour,minute,second,millisecond);return d.getFullYear()===year&&d.getMonth()+1===month&&d.getDate()===day&&d.getHours()===hour&&d.getMinutes()===minute&&d.getSeconds()===second&&d.getMilliseconds()===millisecond}function assertValidDate(year,month,day,hour,minute,second,millisecond){if(!isValidDate(year,month,day,hour,minute,second,millisecond))throw new Error(`Expected valid date. Got: ${JSON.stringify({year,month,day,hour,minute,second,millisecond})}.`)}function isValidDateMonth(month){return Number.isInteger(month)&&1<=month&&12>=month}function assertValidDateMonth(month){if(!isValidDateMonth(month))throw new Error(`Invalid month: ${month}.`)}function isValidDateYear(year){return Number.isInteger(year)&&0<=year}function assertValidDateYear(year){if(!isValidDateYear(year))throw new Error(`Invalid year: ${year}.`)}function isLeapYear(year){return assertValidDateYear(year),0==year%4&&0!=year%100||0==year%400}function numDaysInMonth(month,year){assertValidDateMonth(month);return 2===month&&year!==void 0&&isLeapYear(year)?29:[0,31,28,31,30,31,30,31,31,30,31,30,31][month]}function isValidDateDay(day,month,year){return!!Number.isInteger(day)&&!!Number.isInteger(month)&&(!year||Number.isInteger(year))&&!(1>day)&&!(day>numDaysInMonth(month,year))}function assertValidDateDay(day,month,year){if(!isValidDateDay(day,month,year))throw new Error(`Invalid day of the month: ${day}.`)}const MS_IN_DAY=86400000,MS_IN_HOUR=3600000,MS_IN_MINUTE=60000,MS_IN_MONTH=2628000000,MS_IN_SECOND=1e3,MS_IN_WEEK=604800000,MS_IN_YEAR=31536000000;function dateDaysAgo(days){const date=new Date;return date.setDate(date.getDate()-days),date}function dateWeekDayName(date){return names[date.getDay()]}const names=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function msSinceDate(date){if("number"==typeof date){if(!Number.isInteger(date))throw new Error("Expected date to be a Date or an integer. Got: "+date);date=new Date(date)}return Date.now()-date.getTime()}function daysSinceDate(date){return msSinceDate(date)/MS_IN_DAY}function getCentury(year){return assertValidDateYear(year),Math.floor(year/100)+1}function getCurrentYear(){return new Date().getUTCFullYear()}function hoursSinceDate(date){return msSinceDate(date)/MS_IN_HOUR}function isoDateTimestamp(date=new Date){return date.toISOString().replace(/\D/g,"")}function isoDateTimestampForFilename(date=new Date){return date.toISOString().replace(/[-:T.]/g,"-").replace("Z","")}function minutesSinceDate(date){return msSinceDate(date)/MS_IN_MINUTE}function monthsSinceDate(date){return msSinceDate(date)/MS_IN_MONTH}function prettyIsoDateString(iso,dateTimeSeparator=" ",precision="millisecond"){return iso.substring(0,map[precision]).replace(/T/,dateTimeSeparator).replace(/-|:/g,".")}const map={year:4,month:7,day:10,hour:13,minute:16,second:19,millisecond:23};function secondsSinceDate(date){return msSinceDate(date)/MS_IN_SECOND}function weeksSinceDate(date){return msSinceDate(date)/MS_IN_WEEK}function yearsSinceDate(date){return msSinceDate(date)/MS_IN_YEAR}export{MS_IN_DAY,MS_IN_HOUR,MS_IN_MINUTE,MS_IN_MONTH,MS_IN_SECOND,MS_IN_WEEK,MS_IN_YEAR,assertValidDate,assertValidDateDay,assertValidDateMonth,assertValidDateYear,dateDaysAgo,dateWeekDayName,daysSinceDate,getCentury,getCurrentYear,hoursSinceDate,isLeapYear,isValidDate,isValidDateDay,isValidDateMonth,isValidDateYear,isoDateTimestamp,isoDateTimestampForFilename,minutesSinceDate,monthsSinceDate,msSinceDate,numDaysInMonth,prettyIsoDateString,secondsSinceDate,weeksSinceDate,yearsSinceDate};
5
+ */function isValidDate(year,month,day,hour,minute,second,millisecond){year=year?+year:0,month=month?+month:0,day=day?+day:0,hour=hour?+hour:0,minute=minute?+minute:0,second=second?+second:0,millisecond=millisecond?+millisecond:0;const d=new Date(year,month-1,day,hour,minute,second,millisecond);return d.getFullYear()===year&&d.getMonth()+1===month&&d.getDate()===day&&d.getHours()===hour&&d.getMinutes()===minute&&d.getSeconds()===second&&d.getMilliseconds()===millisecond}function assertValidDate(year,month,day,hour,minute,second,millisecond){if(!isValidDate(year,month,day,hour,minute,second,millisecond))throw new Error(`Expected valid date. Got: ${JSON.stringify({year,month,day,hour,minute,second,millisecond})}.`)}function isValidDateMonth(month){return Number.isInteger(month)&&1<=month&&12>=month}function assertValidDateMonth(month){if(!isValidDateMonth(month))throw new Error(`Invalid month: ${month}.`)}function isValidDateYear(year){return Number.isInteger(year)&&0<=year}function assertValidDateYear(year){if(!isValidDateYear(year))throw new Error(`Invalid year: ${year}.`)}function isLeapYear(year){return assertValidDateYear(year),0==year%4&&0!=year%100||0==year%400}function numDaysInMonth(month,year){assertValidDateMonth(month);return 2===month&&year!==void 0&&isLeapYear(year)?29:[0,31,28,31,30,31,30,31,31,30,31,30,31][month]}function isValidDateDay(day,month,year){return!!Number.isInteger(day)&&!!Number.isInteger(month)&&(!year||Number.isInteger(year))&&!(1>day)&&!(day>numDaysInMonth(month,year))}function assertValidDateDay(day,month,year){if(!isValidDateDay(day,month,year))throw new Error(`Invalid day of the month: ${day}.`)}const MS_IN_DAY=86400000,MS_IN_HOUR=3600000,MS_IN_MINUTE=60000,MS_IN_MONTH=2628000000,MS_IN_SECOND=1e3,MS_IN_WEEK=604800000,MS_IN_YEAR=31536000000;function dateDaysAgo(days){const date=new Date;return date.setDate(date.getDate()-days),date}function dateWeekDayName(date){return names[date.getDay()]}const names=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function msSinceDate(date){if("number"==typeof date){if(!Number.isInteger(date))throw new Error("Expected date to be a Date or an integer. Got: "+date);date=new Date(date)}return Date.now()-date.getTime()}function daysSinceDate(date){return msSinceDate(date)/MS_IN_DAY}function getCentury(year){return assertValidDateYear(year),Math.floor(year/100)+1}function getCurrentYear(){return new Date().getUTCFullYear()}function hoursSinceDate(date){return msSinceDate(date)/MS_IN_HOUR}function isoDateTimestamp(date=new Date){return date.toISOString().replace(/\D/g,"")}function isoDateTimestampForFilename(date=new Date){return date.toISOString().replace(/[-:T.]/g,"-").replace("Z","")}function minutesSinceDate(date){return msSinceDate(date)/MS_IN_MINUTE}function monthsSinceDate(date){return msSinceDate(date)/MS_IN_MONTH}function prettyIsoDateString(iso,dateTimeSeparator="_",precision="millisecond"){return iso.substring(0,map[precision]).replace(/T/,dateTimeSeparator).replace(/-|:/g,".")}const map={year:4,month:7,day:10,hour:13,minute:16,second:19,millisecond:23};function secondsSinceDate(date){return msSinceDate(date)/MS_IN_SECOND}function weeksSinceDate(date){return msSinceDate(date)/MS_IN_WEEK}function yearsSinceDate(date){return msSinceDate(date)/MS_IN_YEAR}export{MS_IN_DAY,MS_IN_HOUR,MS_IN_MINUTE,MS_IN_MONTH,MS_IN_SECOND,MS_IN_WEEK,MS_IN_YEAR,assertValidDate,assertValidDateDay,assertValidDateMonth,assertValidDateYear,dateDaysAgo,dateWeekDayName,daysSinceDate,getCentury,getCurrentYear,hoursSinceDate,isLeapYear,isValidDate,isValidDateDay,isValidDateMonth,isValidDateYear,isoDateTimestamp,isoDateTimestampForFilename,minutesSinceDate,monthsSinceDate,msSinceDate,numDaysInMonth,prettyIsoDateString,secondsSinceDate,weeksSinceDate,yearsSinceDate};
6
6
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/lib/isValidDate.ts","../src/lib/assertValidDate.ts","../src/lib/isValidDateMonth.ts","../src/lib/assertValidDateMonth.ts","../src/lib/isValidDateYear.ts","../src/lib/assertValidDateYear.ts","../src/lib/isLeapYear.ts","../src/lib/numDaysInMonth.ts","../src/lib/isValidDateDay.ts","../src/lib/assertValidDateDay.ts","../src/lib/constants/MS_IN_DAY.ts","../src/lib/constants/MS_IN_HOUR.ts","../src/lib/constants/MS_IN_MINUTE.ts","../src/lib/constants/MS_IN_MONTH.ts","../src/lib/constants/MS_IN_SECOND.ts","../src/lib/constants/MS_IN_WEEK.ts","../src/lib/constants/MS_IN_YEAR.ts","../src/lib/dateDaysAgo.ts","../src/lib/dateWeekDayName.ts","../src/lib/msSinceDate.ts","../src/lib/daysSinceDate.ts","../src/lib/getCentury.ts","../src/lib/getCurrentYear.ts","../src/lib/hoursSinceDate.ts","../src/lib/isoDateTimestamp.ts","../src/lib/isoDateTimestampForFilename.ts","../src/lib/minutesSinceDate.ts","../src/lib/monthsSinceDate.ts","../src/lib/prettyIsoDateString.ts","../src/lib/secondsSinceDate.ts","../src/lib/weeksSinceDate.ts","../src/lib/yearsSinceDate.ts"],"sourcesContent":["/**\n * Checks if the provided date and time values form a valid date.\n * @param year The year of the date.\n * @param month The month of the date.\n * @param day The day of the date.\n * @param hour The hour of the time.\n * @param minute The minute of the time.\n * @param second The second of the time.\n * @param millisecond The millisecond of the time.\n * @returns A boolean indicating whether the provided date and time values form a valid date.\n * @example ```ts\n * isValidDate(2021, 12, 31, 23, 59, 59, 999);;\n * //=> true\n * isValidDate('2021', '12', '31', '23', '59', '59', '999');;\n * //=> true\n * isValidDate(2021, 13, 31, 23, 59, 59, 999);;\n * //=> false\n * ```\n */\nexport function isValidDate(\n year?: number | string,\n month?: number | string,\n day?: number | string,\n hour?: number | string,\n minute?: number | string,\n second?: number | string,\n millisecond?: number | string,\n): boolean {\n year = year ? Number(year) : 0\n month = month ? Number(month) : 0\n day = day ? Number(day) : 0\n hour = hour ? Number(hour) : 0\n minute = minute ? Number(minute) : 0\n second = second ? Number(second) : 0\n millisecond = millisecond ? Number(millisecond) : 0\n const d = new Date(year, month - 1, day, hour, minute, second, millisecond)\n return (\n d.getFullYear() === year &&\n d.getMonth() + 1 === month &&\n d.getDate() === day &&\n d.getHours() === hour &&\n d.getMinutes() === minute &&\n d.getSeconds() === second &&\n d.getMilliseconds() === millisecond\n )\n}\n","import { isValidDate } from './isValidDate'\n\n/**\n * Asserts that the provided date parameters form a valid date.\n * @param year The year of the date.\n * @param month The month of the date.\n * @param day The day of the date.\n * @param hour The hour of the date.\n * @param minute The minute of the date.\n * @param second The second of the date.\n * @param millisecond The millisecond of the date.\n * @throws Will throw an error if the date is not valid.\n * @example ```ts\n * assertValidDate(2021, 12, 31, 23, 59, 59, 999);;\n * //=> true\n * assertValidDate(2021, 13, 31, 23, 59, 59, 999);;\n * //=> throws an error\n * ```\n */\nexport function assertValidDate(\n year?: number | string,\n month?: number | string,\n day?: number | string,\n hour?: number | string,\n minute?: number | string,\n second?: number | string,\n millisecond?: number | string,\n): void {\n if (!isValidDate(year, month, day, hour, minute, second, millisecond)) {\n throw new Error(\n `Expected valid date. Got: ${JSON.stringify({\n year,\n month,\n day,\n hour,\n minute,\n second,\n millisecond,\n })}.`,\n )\n }\n}\n","/**\n * Checks if the provided month is a valid month number (1-12).\n * @param month The month number to validate.\n * @returns A boolean indicating whether the month is valid.\n * @example ```ts\n * isValidDateMonth(5);;\n * //=> true\n * isValidDateMonth(13);;\n * //=> false\n * ```\n */\nexport function isValidDateMonth(month: number): boolean {\n return Number.isInteger(month) && month >= 1 && month <= 12\n}\n","import { isValidDateMonth } from './isValidDateMonth'\n\n/**\n * Asserts if the provided month is a valid date month.\n * @param month The month to be validated. Should be a number between 1 and 12.\n * @throws Will throw an error if the month is not a valid date month.\n * @example ```ts\n * assertValidDateMonth(13);;\n * //=> Error: Invalid month: 13.\n * assertValidDateMonth(1);;\n * //=> undefined\n * ```\n */\nexport function assertValidDateMonth(month: number): void {\n if (!isValidDateMonth(month)) throw new Error(`Invalid month: ${month}.`)\n}\n","/**\n * Checks if the provided year is a valid date year.\n * @remarks This function will return true if the year is a positive integer, false otherwise.\n * @param year The year to be checked.\n * @returns A boolean indicating whether the year is valid or not.\n * @example ```ts\n * isValidDateYear(2020); ;\n * //=> true\n * isValidDateYear(-2020);;\n * //=> false\n * isValidDateYear(2020.5);;\n * //=> false\n * ```\n */\nexport function isValidDateYear(year: number): boolean {\n return Number.isInteger(year) && year >= 0\n}\n","import { isValidDateYear } from './isValidDateYear'\n\n/**\n * Asserts that the provided year is a valid date year.\n * @param year The year to be validated\n * @throws Will throw an error if the year is not valid.\n * @example ```ts\n * assertValidDateYear(2020);;\n * //=> undefined\n * assertValidDateYear(10000);;\n * //=> Error: Invalid year: 10000.\n * ```\n * @returns void\n */\nexport function assertValidDateYear(year: number): void {\n if (!isValidDateYear(year)) throw new Error(`Invalid year: ${year}.`)\n}\n","import { assertValidDateYear } from './assertValidDateYear'\n\n/**\n * Checks if a given year is a leap year.\n * A leap year is exactly divisible by 4 except for century years (years ending with 00).\n * The century year is a leap year only if it is perfectly divisible by 400.\n * @param year The year to check. Must be a valid year number.\n * @returns `true` if the year is a leap year, `false` otherwise.\n * @throws Will throw an error if the year is not a valid number.\n * @example ```ts\n * isLeapYear(2000); ;\n * //=> true\n * isLeapYear(2001); ;\n * //=> false\n * ```\n */\nexport function isLeapYear(year: number): boolean {\n assertValidDateYear(year)\n return (0 == year % 4 && 0 != year % 100) || 0 == year % 400\n}\n","import { assertValidDateMonth } from './assertValidDateMonth'\nimport { isLeapYear } from './isLeapYear'\n\n/**\n * Get number of days that there are in a given month of a given year.\n * Note: The number of days in february depends on whether it is leap year. If no year is given, it is assumed that it is not leap year.\n * @param month The month for which the number of days is to be calculated. Should be a number between 1 and 12.\n * @param year The year for which the number of days in the month is to be calculated. Optional.\n * @returns The number of days in the given month for the specified year.\n * @throws Will throw an error if the month is not a valid number between 1 and 12.\n * @example ```ts\n * numDaysInMonth(2, 2020);;\n * //=> 29\n * numDaysInMonth(2);;\n * //=> 28\n * numDaysInMonth(1);;\n * //=> 31\n * ```\n */\nexport function numDaysInMonth(month: number, year?: number): number {\n assertValidDateMonth(month)\n const DAYS_IN_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n return month === 2 && year !== undefined && isLeapYear(year) ? 29 : DAYS_IN_MONTH[month]\n}\n","import { numDaysInMonth } from './numDaysInMonth'\n\n/**\n * Checks if the given day is a valid day of the month.\n * @param day The day of the month. Must be an integer.\n * @param month The month of the year. Must be an integer.\n * @param year The year. Optional parameter. If not provided, the function will not check for leap years.\n * @returns A boolean indicating whether the day is valid for the given month and year.\n * @example ```ts\n * isValidDateDay(31, 1, 2000);\n * //=> true\n * isValidDateDay(31, 2, 2000);\n * //=> false\n * isValidDateDay(29, 2);\n * //=> true\n * ```\n */\nexport function isValidDateDay(day: number, month: number, year?: number): boolean {\n if (!Number.isInteger(day)) return false\n if (!Number.isInteger(month)) return false\n if (year && !Number.isInteger(year)) return false\n if (day < 1) return false\n if (day > numDaysInMonth(month, year)) return false\n return true\n}\n","import { isValidDateDay } from './isValidDateDay'\n\n/**\n * Asserts that the provided day, month, and optional year form a valid date.\n * If the date is not valid, it throws an error.\n * @param day The day of the month. Should be an integer between 1 and 31.\n * @param month The month of the year. Should be an integer between 1 and 12.\n * @param year The year of the date. Optional parameter. If provided, should be a positive integer.\n * @throws Will throw an error if the provided day, month, and optional year do not form a valid date.\n * @example ```ts\n * assertValidDateDay(31, 2, 2020);;\n * //=> Error: Invalid day of the month: 31.\n * assertValidDateDay(29, 2, 2020);;\n * //=> no error\n * ```\n */\nexport function assertValidDateDay(day: number, month: number, year?: number): void {\n if (!isValidDateDay(day, month, year)) throw new Error(`Invalid day of the month: ${day}.`)\n}\n","/**\n * The number of milliseconds in a day.\n */\nexport const MS_IN_DAY = 1000 * 60 * 60 * 24\n","/**\n * The number of milliseconds in an hour.\n */\nexport const MS_IN_HOUR = 1000 * 60 * 60\n","/**\n * The number of milliseconds in a minute.\n */\nexport const MS_IN_MINUTE = 1000 * 60\n","/**\n * The number of milliseconds in a month.\n */\nexport const MS_IN_MONTH = (1000 * 60 * 60 * 24 * 365) / 12\n","/**\n * The number of milliseconds in a second.\n */\nexport const MS_IN_SECOND = 1000\n","/**\n * The number of milliseconds in a week.\n */\nexport const MS_IN_WEEK = 1000 * 60 * 60 * 24 * 7\n","/**\n * The number of milliseconds in a year.\n */\nexport const MS_IN_YEAR = 1000 * 60 * 60 * 24 * 365\n","/**\n * Returns a Date object representing a date that is a certain number of days in the past.\n * @param days The number of days ago for the date to represent.\n * @returns A Date object representing the date that is the specified number of days in the past.\n * @example ```ts\n * dateDaysAgo(5);;\n * //=> result\n * ```\n */\nexport function dateDaysAgo(days: number): Date {\n const date = new Date()\n date.setDate(date.getDate() - days)\n return date\n}\n","export function dateWeekDayName(date: Date) {\r\n return names[date.getDay()]\r\n}\r\n\r\nconst names = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']\r\n","/**\n * Calculates the number of milliseconds that have passed since the provided date.\n * @param date The date from which to calculate the elapsed time.\n * @throws If the provided date is not a Date object or an integer.\n * @returns The number of milliseconds that have passed since the provided date.\n * @example ```ts\n * msSinceDate(new Date('2020-01-01'));;\n * //=> {number of milliseconds since 2020-01-01}\n * ```\n */\nexport function msSinceDate(date: Date | number): number {\n if (typeof date === 'number') {\n if (!Number.isInteger(date)) {\n throw new Error('Expected date to be a Date or an integer. Got: ' + date)\n }\n date = new Date(date)\n }\n return Date.now() - date.getTime()\n}\n","import { MS_IN_DAY } from './constants/MS_IN_DAY'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of days that have passed since the given date.\n * @param date The date from which to calculate the number of days passed.\n * @returns The number of days since the given date.\n * @example ```ts\n * new Date('2020-01-01');;\n * //=> <date object>\n * daysSinceDate(new Date('2020-01-01'));;\n * //=> <number of days since 2020-01-01>\n * ```\n */\nexport function daysSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_DAY\n}\n","import { assertValidDateYear } from './assertValidDateYear'\n\n/**\n * This function takes a year as a parameter and returns the century it belongs to.\n * @param year The year to determine the century for. Must be a valid year number.\n * @returns The century the year belongs to.\n * @throws Will throw an error if the year is not a valid number.\n * @example ```ts\n * getCentury(2000);;\n * //=> 20\n * getCentury(1899);;\n * //=> 19\n * ```\n */\nexport function getCentury(year: number): number {\n assertValidDateYear(year)\n return Math.floor(year / 100) + 1\n}\n","/**\n * Returns the current year as a number.\n * @remarks This function uses the `getUTCFullYear` method of the `Date` object to get the current year.\n * @returns The current year as a number.\n * @example ```ts\n * getCurrentYear();;\n * //=> 2022\n * ```\n */\nexport function getCurrentYear(): number {\n return new Date().getUTCFullYear()\n}\n","import { MS_IN_HOUR } from './constants/MS_IN_HOUR'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of hours that have passed since the given date.\n * @param date The date from which to calculate the number of hours passed.\n * @returns The number of hours that have passed since the given date.\n * @example ```ts\n * new Date('2020-01-01T00:00:00Z');;\n * //=> {date object}\n * hoursSinceDate(new Date('2020-01-01T00:00:00Z'));;\n * //=> {number of hours since January 1, 2020}\n * ```\n */\nexport function hoursSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_HOUR\n}\n","/**\n * Converts a given date to an ISO date timestamp string.\n * If no date is provided, the current date and time will be used.\n * @param - The date to convert. Defaults to the current date and time.\n * @returns The ISO date timestamp string.\n * @example ```ts\n * isoDateTimestamp(new Date('2020-01-01T00:00:00Z'));;\n * //=> \"20200101T000000Z\"\n * ```\n * @example ```ts\n * const timestamp = isoDateTimestamp();\n * console.log(timestamp); // Outputs the current date and time in ISO format, e.g. \"20210520T102030Z\"\n * ```\n */\nexport function isoDateTimestamp(date = new Date()): string {\n return date.toISOString().replace(/\\D/g, '')\n}\n","/**\n * This function takes a date object and returns a string in ISO format suitable for filenames.\n * If no date is provided, it uses the current date and time.\n * @param date The date object to be converted. Defaults to the current date and time.\n * @returns A string in the format \"YYYY-MM-DD-HH-MM-SS-SSS\".\n * @example ```ts\n * isoDateTimestampForFilename(new Date('2022-01-01T00:00:00Z'));;\n * //=> \"2022-01-01-00-00-00-000\"\n * ```\n */\nexport function isoDateTimestampForFilename(date = new Date()): string {\n return date\n .toISOString()\n .replace(/[-:T.]/g, '-')\n .replace('Z', '')\n}\n","import { MS_IN_MINUTE } from './constants/MS_IN_MINUTE'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of minutes that have passed since the given date.\n * @param date The date from which to calculate the number of minutes that have passed.\n * @returns The number of minutes that have passed since the given date.\n * @example ```ts\n * new Date('2020-01-01T00:00:00Z');;\n * //=> {date}\n * minutesSinceDate(new Date('2020-01-01T00:00:00Z'));;\n * //=> {number of minutes since 2020-01-01T00:00:00Z}\n * ```\n */\nexport function minutesSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_MINUTE\n}\n","import { MS_IN_MONTH } from './constants/MS_IN_MONTH'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of months that have passed since the provided date.\n * @param date The date from which to calculate the number of passed months.\n * @returns The number of months that have passed since the provided date.\n * @example ```ts\n * new Date(2020, 0, 1);;\n * //=> {date}\n * monthsSinceDate(new Date(2020, 0, 1));;\n * //=> {number of months since January 1, 2020}\n * ```\n */\nexport function monthsSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_MONTH\n}\n","export function prettyIsoDateString(\r\n iso: string,\r\n dateTimeSeparator = ' ',\r\n precision: 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond' = 'millisecond',\r\n) {\r\n return iso.substring(0, map[precision]).replace(/T/, dateTimeSeparator).replace(/-|:/g, '.')\r\n}\r\n\r\nconst map = {\r\n year: 4,\r\n month: 7,\r\n day: 10,\r\n hour: 13,\r\n minute: 16,\r\n second: 19,\r\n millisecond: 23,\r\n}\r\n\r\n// const s = '2020-02-03T14:01:04.437Z'\r\n// console.log(prettyIsoDateString(s, ' ', 'year'))\r\n// console.log(prettyIsoDateString(s, ' ', 'month'))\r\n// console.log(prettyIsoDateString(s, ' ', 'day'))\r\n// console.log(prettyIsoDateString(s, ' ', 'hour'))\r\n// console.log(prettyIsoDateString(s, ' ', 'minute'))\r\n// console.log(prettyIsoDateString(s, ' ', 'second'))\r\n// console.log(prettyIsoDateString(s, ' ', 'millisecond'))\r\n","import { MS_IN_SECOND } from './constants/MS_IN_SECOND'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Returns the number of seconds that have passed since the given date.\n * @param date The date from which to calculate the number of seconds.\n * @returns The number of seconds since the given date.\n * @example ```ts\n * secondsSinceDate(new Date('2020-01-01'));;\n * //=> {number of seconds since 2020-01-01}\n * ```\n */\nexport function secondsSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_SECOND\n}\n","import { MS_IN_WEEK } from './constants/MS_IN_WEEK'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of weeks that have passed since the provided date.\n * @param date The date from which to calculate the number of weeks passed.\n * @returns The number of weeks since the provided date.\n * @example ```ts\n * weeksSinceDate(new Date('2020-01-01'));;\n * //=> {number of weeks since '2020-01-01'}\n * ```\n */\nexport function weeksSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_WEEK\n}\n","import { MS_IN_YEAR } from './constants/MS_IN_YEAR'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of years that have passed since the provided date.\n * @param date The date from which to calculate the number of years passed.\n * @returns The number of years that have passed since the provided date.\n * @example ```ts\n * yearsSinceDate(new Date('2000-01-01'));;\n * //=> {number of years since '2000-01-01'}\n * ```\n */\nexport function yearsSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_YEAR\n}\n"],"names":["isValidDate","year","month","day","hour","minute","second","millisecond","d","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","getMilliseconds","assertValidDate","Error","JSON","stringify","isValidDateMonth","Number","isInteger","assertValidDateMonth","isValidDateYear","assertValidDateYear","isLeapYear","numDaysInMonth","isValidDateDay","assertValidDateDay","MS_IN_DAY","MS_IN_HOUR","MS_IN_MINUTE","MS_IN_MONTH","MS_IN_SECOND","MS_IN_WEEK","MS_IN_YEAR","dateDaysAgo","days","date","setDate","dateWeekDayName","names","getDay","msSinceDate","now","getTime","daysSinceDate","getCentury","Math","floor","getCurrentYear","getUTCFullYear","hoursSinceDate","isoDateTimestamp","toISOString","replace","isoDateTimestampForFilename","minutesSinceDate","monthsSinceDate","prettyIsoDateString","iso","dateTimeSeparator","precision","substring","map","secondsSinceDate","weeksSinceDate","yearsSinceDate"],"mappings":";;;;GAmBgB,QAAA,CAAAA,WAAWA,CACzBC,IAAsB,CACtBC,KAAuB,CACvBC,GAAqB,CACrBC,IAAsB,CACtBC,MAAwB,CACxBC,MAAwB,CACxBC,WAA6B,CAAA,CAE7BN,IAAI,CAAGA,IAAI,EAAUA,IAAI,CAAI,CAAC,CAC9BC,KAAK,CAAGA,KAAK,EAAUA,KAAK,CAAI,CAAC,CACjCC,GAAG,CAAGA,GAAG,EAAUA,GAAG,CAAI,CAAC,CAC3BC,IAAI,CAAGA,IAAI,EAAUA,IAAI,CAAI,CAAC,CAC9BC,MAAM,CAAGA,MAAM,EAAUA,MAAM,CAAI,CAAC,CACpCC,MAAM,CAAGA,MAAM,EAAUA,MAAM,CAAI,CAAC,CACpCC,WAAW,CAAGA,WAAW,EAAUA,WAAW,CAAI,CAAC,CACnD,KAAM,CAAAC,CAAC,CAAG,GAAI,CAAAC,IAAI,CAACR,IAAI,CAAEC,KAAK,CAAG,CAAC,CAAEC,GAAG,CAAEC,IAAI,CAAEC,MAAM,CAAEC,MAAM,CAAEC,WAAW,CAAC,CAC3E,MACE,CAAAC,CAAC,CAACE,WAAW,CAAA,CAAE,GAAKT,IAAI,EACxBO,CAAC,CAACG,QAAQ,EAAE,CAAG,CAAC,GAAKT,KAAK,EAC1BM,CAAC,CAACI,OAAO,CAAA,CAAE,GAAKT,GAAG,EACnBK,CAAC,CAACK,QAAQ,CAAA,CAAE,GAAKT,IAAI,EACrBI,CAAC,CAACM,UAAU,CAAA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C5B,IAAmB,CAAA,CAChD,MAAO,CAAAK,WAAW,CAACL,IAAI,CAAC,CAAGJ,UAC7B,CCFM,QAAU,CAAAiC,cAAcA,CAAC7B,IAAmB,CAAA,CAChD,MAAO,CAAAK,WAAW,CAACL,IAAI,CAAC,CAAGH,UAC7B"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/lib/isValidDate.ts","../src/lib/assertValidDate.ts","../src/lib/isValidDateMonth.ts","../src/lib/assertValidDateMonth.ts","../src/lib/isValidDateYear.ts","../src/lib/assertValidDateYear.ts","../src/lib/isLeapYear.ts","../src/lib/numDaysInMonth.ts","../src/lib/isValidDateDay.ts","../src/lib/assertValidDateDay.ts","../src/lib/constants/MS_IN_DAY.ts","../src/lib/constants/MS_IN_HOUR.ts","../src/lib/constants/MS_IN_MINUTE.ts","../src/lib/constants/MS_IN_MONTH.ts","../src/lib/constants/MS_IN_SECOND.ts","../src/lib/constants/MS_IN_WEEK.ts","../src/lib/constants/MS_IN_YEAR.ts","../src/lib/dateDaysAgo.ts","../src/lib/dateWeekDayName.ts","../src/lib/msSinceDate.ts","../src/lib/daysSinceDate.ts","../src/lib/getCentury.ts","../src/lib/getCurrentYear.ts","../src/lib/hoursSinceDate.ts","../src/lib/isoDateTimestamp.ts","../src/lib/isoDateTimestampForFilename.ts","../src/lib/minutesSinceDate.ts","../src/lib/monthsSinceDate.ts","../src/lib/prettyIsoDateString.ts","../src/lib/secondsSinceDate.ts","../src/lib/weeksSinceDate.ts","../src/lib/yearsSinceDate.ts"],"sourcesContent":["/**\n * Checks if the provided date and time values form a valid date.\n * @param year The year of the date.\n * @param month The month of the date.\n * @param day The day of the date.\n * @param hour The hour of the time.\n * @param minute The minute of the time.\n * @param second The second of the time.\n * @param millisecond The millisecond of the time.\n * @returns A boolean indicating whether the provided date and time values form a valid date.\n * @example ```ts\n * isValidDate(2021, 12, 31, 23, 59, 59, 999);;\n * //=> true\n * isValidDate('2021', '12', '31', '23', '59', '59', '999');;\n * //=> true\n * isValidDate(2021, 13, 31, 23, 59, 59, 999);;\n * //=> false\n * ```\n */\nexport function isValidDate(\n year?: number | string,\n month?: number | string,\n day?: number | string,\n hour?: number | string,\n minute?: number | string,\n second?: number | string,\n millisecond?: number | string,\n): boolean {\n year = year ? Number(year) : 0\n month = month ? Number(month) : 0\n day = day ? Number(day) : 0\n hour = hour ? Number(hour) : 0\n minute = minute ? Number(minute) : 0\n second = second ? Number(second) : 0\n millisecond = millisecond ? Number(millisecond) : 0\n const d = new Date(year, month - 1, day, hour, minute, second, millisecond)\n return (\n d.getFullYear() === year &&\n d.getMonth() + 1 === month &&\n d.getDate() === day &&\n d.getHours() === hour &&\n d.getMinutes() === minute &&\n d.getSeconds() === second &&\n d.getMilliseconds() === millisecond\n )\n}\n","import { isValidDate } from './isValidDate'\n\n/**\n * Asserts that the provided date parameters form a valid date.\n * @param year The year of the date.\n * @param month The month of the date.\n * @param day The day of the date.\n * @param hour The hour of the date.\n * @param minute The minute of the date.\n * @param second The second of the date.\n * @param millisecond The millisecond of the date.\n * @throws Will throw an error if the date is not valid.\n * @example ```ts\n * assertValidDate(2021, 12, 31, 23, 59, 59, 999);;\n * //=> true\n * assertValidDate(2021, 13, 31, 23, 59, 59, 999);;\n * //=> throws an error\n * ```\n */\nexport function assertValidDate(\n year?: number | string,\n month?: number | string,\n day?: number | string,\n hour?: number | string,\n minute?: number | string,\n second?: number | string,\n millisecond?: number | string,\n): void {\n if (!isValidDate(year, month, day, hour, minute, second, millisecond)) {\n throw new Error(\n `Expected valid date. Got: ${JSON.stringify({\n year,\n month,\n day,\n hour,\n minute,\n second,\n millisecond,\n })}.`,\n )\n }\n}\n","/**\n * Checks if the provided month is a valid month number (1-12).\n * @param month The month number to validate.\n * @returns A boolean indicating whether the month is valid.\n * @example ```ts\n * isValidDateMonth(5);;\n * //=> true\n * isValidDateMonth(13);;\n * //=> false\n * ```\n */\nexport function isValidDateMonth(month: number): boolean {\n return Number.isInteger(month) && month >= 1 && month <= 12\n}\n","import { isValidDateMonth } from './isValidDateMonth'\n\n/**\n * Asserts if the provided month is a valid date month.\n * @param month The month to be validated. Should be a number between 1 and 12.\n * @throws Will throw an error if the month is not a valid date month.\n * @example ```ts\n * assertValidDateMonth(13);;\n * //=> Error: Invalid month: 13.\n * assertValidDateMonth(1);;\n * //=> undefined\n * ```\n */\nexport function assertValidDateMonth(month: number): void {\n if (!isValidDateMonth(month)) throw new Error(`Invalid month: ${month}.`)\n}\n","/**\n * Checks if the provided year is a valid date year.\n * @remarks This function will return true if the year is a positive integer, false otherwise.\n * @param year The year to be checked.\n * @returns A boolean indicating whether the year is valid or not.\n * @example ```ts\n * isValidDateYear(2020); ;\n * //=> true\n * isValidDateYear(-2020);;\n * //=> false\n * isValidDateYear(2020.5);;\n * //=> false\n * ```\n */\nexport function isValidDateYear(year: number): boolean {\n return Number.isInteger(year) && year >= 0\n}\n","import { isValidDateYear } from './isValidDateYear'\n\n/**\n * Asserts that the provided year is a valid date year.\n * @param year The year to be validated\n * @throws Will throw an error if the year is not valid.\n * @example ```ts\n * assertValidDateYear(2020);;\n * //=> undefined\n * assertValidDateYear(10000);;\n * //=> Error: Invalid year: 10000.\n * ```\n * @returns void\n */\nexport function assertValidDateYear(year: number): void {\n if (!isValidDateYear(year)) throw new Error(`Invalid year: ${year}.`)\n}\n","import { assertValidDateYear } from './assertValidDateYear'\n\n/**\n * Checks if a given year is a leap year.\n * A leap year is exactly divisible by 4 except for century years (years ending with 00).\n * The century year is a leap year only if it is perfectly divisible by 400.\n * @param year The year to check. Must be a valid year number.\n * @returns `true` if the year is a leap year, `false` otherwise.\n * @throws Will throw an error if the year is not a valid number.\n * @example ```ts\n * isLeapYear(2000); ;\n * //=> true\n * isLeapYear(2001); ;\n * //=> false\n * ```\n */\nexport function isLeapYear(year: number): boolean {\n assertValidDateYear(year)\n return (0 == year % 4 && 0 != year % 100) || 0 == year % 400\n}\n","import { assertValidDateMonth } from './assertValidDateMonth'\nimport { isLeapYear } from './isLeapYear'\n\n/**\n * Get number of days that there are in a given month of a given year.\n * Note: The number of days in february depends on whether it is leap year. If no year is given, it is assumed that it is not leap year.\n * @param month The month for which the number of days is to be calculated. Should be a number between 1 and 12.\n * @param year The year for which the number of days in the month is to be calculated. Optional.\n * @returns The number of days in the given month for the specified year.\n * @throws Will throw an error if the month is not a valid number between 1 and 12.\n * @example ```ts\n * numDaysInMonth(2, 2020);;\n * //=> 29\n * numDaysInMonth(2);;\n * //=> 28\n * numDaysInMonth(1);;\n * //=> 31\n * ```\n */\nexport function numDaysInMonth(month: number, year?: number): number {\n assertValidDateMonth(month)\n const DAYS_IN_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n return month === 2 && year !== undefined && isLeapYear(year) ? 29 : DAYS_IN_MONTH[month]\n}\n","import { numDaysInMonth } from './numDaysInMonth'\n\n/**\n * Checks if the given day is a valid day of the month.\n * @param day The day of the month. Must be an integer.\n * @param month The month of the year. Must be an integer.\n * @param year The year. Optional parameter. If not provided, the function will not check for leap years.\n * @returns A boolean indicating whether the day is valid for the given month and year.\n * @example ```ts\n * isValidDateDay(31, 1, 2000);\n * //=> true\n * isValidDateDay(31, 2, 2000);\n * //=> false\n * isValidDateDay(29, 2);\n * //=> true\n * ```\n */\nexport function isValidDateDay(day: number, month: number, year?: number): boolean {\n if (!Number.isInteger(day)) return false\n if (!Number.isInteger(month)) return false\n if (year && !Number.isInteger(year)) return false\n if (day < 1) return false\n if (day > numDaysInMonth(month, year)) return false\n return true\n}\n","import { isValidDateDay } from './isValidDateDay'\n\n/**\n * Asserts that the provided day, month, and optional year form a valid date.\n * If the date is not valid, it throws an error.\n * @param day The day of the month. Should be an integer between 1 and 31.\n * @param month The month of the year. Should be an integer between 1 and 12.\n * @param year The year of the date. Optional parameter. If provided, should be a positive integer.\n * @throws Will throw an error if the provided day, month, and optional year do not form a valid date.\n * @example ```ts\n * assertValidDateDay(31, 2, 2020);;\n * //=> Error: Invalid day of the month: 31.\n * assertValidDateDay(29, 2, 2020);;\n * //=> no error\n * ```\n */\nexport function assertValidDateDay(day: number, month: number, year?: number): void {\n if (!isValidDateDay(day, month, year)) throw new Error(`Invalid day of the month: ${day}.`)\n}\n","/**\n * The number of milliseconds in a day.\n */\nexport const MS_IN_DAY = 1000 * 60 * 60 * 24\n","/**\n * The number of milliseconds in an hour.\n */\nexport const MS_IN_HOUR = 1000 * 60 * 60\n","/**\n * The number of milliseconds in a minute.\n */\nexport const MS_IN_MINUTE = 1000 * 60\n","/**\n * The number of milliseconds in a month.\n */\nexport const MS_IN_MONTH = (1000 * 60 * 60 * 24 * 365) / 12\n","/**\n * The number of milliseconds in a second.\n */\nexport const MS_IN_SECOND = 1000\n","/**\n * The number of milliseconds in a week.\n */\nexport const MS_IN_WEEK = 1000 * 60 * 60 * 24 * 7\n","/**\n * The number of milliseconds in a year.\n */\nexport const MS_IN_YEAR = 1000 * 60 * 60 * 24 * 365\n","/**\n * Returns a Date object representing a date that is a certain number of days in the past.\n * @param days The number of days ago for the date to represent.\n * @returns A Date object representing the date that is the specified number of days in the past.\n * @example ```ts\n * dateDaysAgo(5);;\n * //=> result\n * ```\n */\nexport function dateDaysAgo(days: number): Date {\n const date = new Date()\n date.setDate(date.getDate() - days)\n return date\n}\n","export function dateWeekDayName(date: Date) {\r\n return names[date.getDay()]\r\n}\r\n\r\nconst names = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']\r\n","/**\n * Calculates the number of milliseconds that have passed since the provided date.\n * @param date The date from which to calculate the elapsed time.\n * @throws If the provided date is not a Date object or an integer.\n * @returns The number of milliseconds that have passed since the provided date.\n * @example ```ts\n * msSinceDate(new Date('2020-01-01'));;\n * //=> {number of milliseconds since 2020-01-01}\n * ```\n */\nexport function msSinceDate(date: Date | number): number {\n if (typeof date === 'number') {\n if (!Number.isInteger(date)) {\n throw new Error('Expected date to be a Date or an integer. Got: ' + date)\n }\n date = new Date(date)\n }\n return Date.now() - date.getTime()\n}\n","import { MS_IN_DAY } from './constants/MS_IN_DAY'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of days that have passed since the given date.\n * @param date The date from which to calculate the number of days passed.\n * @returns The number of days since the given date.\n * @example ```ts\n * new Date('2020-01-01');;\n * //=> <date object>\n * daysSinceDate(new Date('2020-01-01'));;\n * //=> <number of days since 2020-01-01>\n * ```\n */\nexport function daysSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_DAY\n}\n","import { assertValidDateYear } from './assertValidDateYear'\n\n/**\n * This function takes a year as a parameter and returns the century it belongs to.\n * @param year The year to determine the century for. Must be a valid year number.\n * @returns The century the year belongs to.\n * @throws Will throw an error if the year is not a valid number.\n * @example ```ts\n * getCentury(2000);;\n * //=> 20\n * getCentury(1899);;\n * //=> 19\n * ```\n */\nexport function getCentury(year: number): number {\n assertValidDateYear(year)\n return Math.floor(year / 100) + 1\n}\n","/**\n * Returns the current year as a number.\n * @remarks This function uses the `getUTCFullYear` method of the `Date` object to get the current year.\n * @returns The current year as a number.\n * @example ```ts\n * getCurrentYear();;\n * //=> 2022\n * ```\n */\nexport function getCurrentYear(): number {\n return new Date().getUTCFullYear()\n}\n","import { MS_IN_HOUR } from './constants/MS_IN_HOUR'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of hours that have passed since the given date.\n * @param date The date from which to calculate the number of hours passed.\n * @returns The number of hours that have passed since the given date.\n * @example ```ts\n * new Date('2020-01-01T00:00:00Z');;\n * //=> {date object}\n * hoursSinceDate(new Date('2020-01-01T00:00:00Z'));;\n * //=> {number of hours since January 1, 2020}\n * ```\n */\nexport function hoursSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_HOUR\n}\n","/**\n * Converts a given date to an ISO date timestamp string.\n * If no date is provided, the current date and time will be used.\n * @param - The date to convert. Defaults to the current date and time.\n * @returns The ISO date timestamp string.\n * @example ```ts\n * isoDateTimestamp(new Date('2020-01-01T00:00:00Z'));;\n * //=> \"20200101T000000Z\"\n * ```\n * @example ```ts\n * const timestamp = isoDateTimestamp();\n * console.log(timestamp); // Outputs the current date and time in ISO format, e.g. \"20210520T102030Z\"\n * ```\n */\nexport function isoDateTimestamp(date = new Date()): string {\n return date.toISOString().replace(/\\D/g, '')\n}\n","/**\n * This function takes a date object and returns a string in ISO format suitable for filenames.\n * If no date is provided, it uses the current date and time.\n * @param date The date object to be converted. Defaults to the current date and time.\n * @returns A string in the format \"YYYY-MM-DD-HH-MM-SS-SSS\".\n * @example ```ts\n * isoDateTimestampForFilename(new Date('2022-01-01T00:00:00Z'));;\n * //=> \"2022-01-01-00-00-00-000\"\n * ```\n */\nexport function isoDateTimestampForFilename(date = new Date()): string {\n return date\n .toISOString()\n .replace(/[-:T.]/g, '-')\n .replace('Z', '')\n}\n","import { MS_IN_MINUTE } from './constants/MS_IN_MINUTE'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of minutes that have passed since the given date.\n * @param date The date from which to calculate the number of minutes that have passed.\n * @returns The number of minutes that have passed since the given date.\n * @example ```ts\n * new Date('2020-01-01T00:00:00Z');;\n * //=> {date}\n * minutesSinceDate(new Date('2020-01-01T00:00:00Z'));;\n * //=> {number of minutes since 2020-01-01T00:00:00Z}\n * ```\n */\nexport function minutesSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_MINUTE\n}\n","import { MS_IN_MONTH } from './constants/MS_IN_MONTH'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of months that have passed since the provided date.\n * @param date The date from which to calculate the number of passed months.\n * @returns The number of months that have passed since the provided date.\n * @example ```ts\n * new Date(2020, 0, 1);;\n * //=> {date}\n * monthsSinceDate(new Date(2020, 0, 1));;\n * //=> {number of months since January 1, 2020}\n * ```\n */\nexport function monthsSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_MONTH\n}\n","export function prettyIsoDateString(\r\n iso: string,\r\n dateTimeSeparator = '_',\r\n precision: 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond' = 'millisecond',\r\n) {\r\n return iso.substring(0, map[precision]).replace(/T/, dateTimeSeparator).replace(/-|:/g, '.')\r\n}\r\n\r\nconst map = {\r\n year: 4,\r\n month: 7,\r\n day: 10,\r\n hour: 13,\r\n minute: 16,\r\n second: 19,\r\n millisecond: 23,\r\n}\r\n\r\n// const s = '2020-02-03T14:01:04.437Z'\r\n// console.log(prettyIsoDateString(s, '_', 'year'))\r\n// console.log(prettyIsoDateString(s, '_', 'month'))\r\n// console.log(prettyIsoDateString(s, '_', 'day'))\r\n// console.log(prettyIsoDateString(s, '_', 'hour'))\r\n// console.log(prettyIsoDateString(s, '_', 'minute'))\r\n// console.log(prettyIsoDateString(s, '_', 'second'))\r\n// console.log(prettyIsoDateString(s, '_', 'millisecond'))\r\n","import { MS_IN_SECOND } from './constants/MS_IN_SECOND'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Returns the number of seconds that have passed since the given date.\n * @param date The date from which to calculate the number of seconds.\n * @returns The number of seconds since the given date.\n * @example ```ts\n * secondsSinceDate(new Date('2020-01-01'));;\n * //=> {number of seconds since 2020-01-01}\n * ```\n */\nexport function secondsSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_SECOND\n}\n","import { MS_IN_WEEK } from './constants/MS_IN_WEEK'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of weeks that have passed since the provided date.\n * @param date The date from which to calculate the number of weeks passed.\n * @returns The number of weeks since the provided date.\n * @example ```ts\n * weeksSinceDate(new Date('2020-01-01'));;\n * //=> {number of weeks since '2020-01-01'}\n * ```\n */\nexport function weeksSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_WEEK\n}\n","import { MS_IN_YEAR } from './constants/MS_IN_YEAR'\nimport { msSinceDate } from './msSinceDate'\n\n/**\n * Calculates the number of years that have passed since the provided date.\n * @param date The date from which to calculate the number of years passed.\n * @returns The number of years that have passed since the provided date.\n * @example ```ts\n * yearsSinceDate(new Date('2000-01-01'));;\n * //=> {number of years since '2000-01-01'}\n * ```\n */\nexport function yearsSinceDate(date: Date | number): number {\n return msSinceDate(date) / MS_IN_YEAR\n}\n"],"names":["isValidDate","year","month","day","hour","minute","second","millisecond","d","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","getMilliseconds","assertValidDate","Error","JSON","stringify","isValidDateMonth","Number","isInteger","assertValidDateMonth","isValidDateYear","assertValidDateYear","isLeapYear","numDaysInMonth","isValidDateDay","assertValidDateDay","MS_IN_DAY","MS_IN_HOUR","MS_IN_MINUTE","MS_IN_MONTH","MS_IN_SECOND","MS_IN_WEEK","MS_IN_YEAR","dateDaysAgo","days","date","setDate","dateWeekDayName","names","getDay","msSinceDate","now","getTime","daysSinceDate","getCentury","Math","floor","getCurrentYear","getUTCFullYear","hoursSinceDate","isoDateTimestamp","toISOString","replace","isoDateTimestampForFilename","minutesSinceDate","monthsSinceDate","prettyIsoDateString","iso","dateTimeSeparator","precision","substring","map","secondsSinceDate","weeksSinceDate","yearsSinceDate"],"mappings":";;;;GAmBgB,QAAA,CAAAA,WAAWA,CACzBC,IAAsB,CACtBC,KAAuB,CACvBC,GAAqB,CACrBC,IAAsB,CACtBC,MAAwB,CACxBC,MAAwB,CACxBC,WAA6B,CAAA,CAE7BN,IAAI,CAAGA,IAAI,EAAUA,IAAI,CAAI,CAAC,CAC9BC,KAAK,CAAGA,KAAK,EAAUA,KAAK,CAAI,CAAC,CACjCC,GAAG,CAAGA,GAAG,EAAUA,GAAG,CAAI,CAAC,CAC3BC,IAAI,CAAGA,IAAI,EAAUA,IAAI,CAAI,CAAC,CAC9BC,MAAM,CAAGA,MAAM,EAAUA,MAAM,CAAI,CAAC,CACpCC,MAAM,CAAGA,MAAM,EAAUA,MAAM,CAAI,CAAC,CACpCC,WAAW,CAAGA,WAAW,EAAUA,WAAW,CAAI,CAAC,CACnD,KAAM,CAAAC,CAAC,CAAG,GAAI,CAAAC,IAAI,CAACR,IAAI,CAAEC,KAAK,CAAG,CAAC,C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AS,GAAG,CAAG,CACVjE,IAAI,CAAE,CAAC,CACPC,KAAK,CAAE,CAAC,CACRC,GAAG,CAAE,EAAE,CACPC,IAAI,CAAE,EAAE,CACRC,MAAM,CAAE,EAAE,CACVC,MAAM,CAAE,EAAE,CACVC,WAAW,CAAE,GACd,CCJK,QAAU,CAAA4D,gBAAgBA,CAAC3B,IAAmB,CAAA,CAClD,MAAO,CAAAK,WAAW,CAACL,IAAI,CAAC,CAAGL,YAC7B,CCFM,QAAU,CAAAiC,cAAcA,CAAC5B,IAAmB,CAAA,CAChD,MAAO,CAAAK,WAAW,CAACL,IAAI,CAAC,CAAGJ,UAC7B,CCFM,QAAU,CAAAiC,cAAcA,CAAC7B,IAAmB,CAAA,CAChD,MAAO,CAAAK,WAAW,CAACL,IAAI,CAAC,CAAGH,UAC7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemoje/date",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Date related tools/util.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",