aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/date-fns/parse/_lib/utils.js
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-06-29 11:49:28 -0700
committerPinapelz <yukais@pinapelz.com>2025-06-29 11:49:28 -0700
commitd55b767039605256c736166a942a9138e3eacfd7 (patch)
tree947063b634c50d438a794325f13275e134aa5993 /node_modules/date-fns/parse/_lib/utils.js
parent864ce67d89c77d8ef9c3361f80d619853abcf91c (diff)
remove dev node_modules (oops)
Diffstat (limited to 'node_modules/date-fns/parse/_lib/utils.js')
-rw-r--r--node_modules/date-fns/parse/_lib/utils.js126
1 files changed, 0 insertions, 126 deletions
diff --git a/node_modules/date-fns/parse/_lib/utils.js b/node_modules/date-fns/parse/_lib/utils.js
deleted file mode 100644
index dba676c..0000000
--- a/node_modules/date-fns/parse/_lib/utils.js
+++ /dev/null
@@ -1,126 +0,0 @@
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.dayPeriodEnumToHours = dayPeriodEnumToHours;
-exports.isLeapYearIndex = isLeapYearIndex;
-exports.mapValue = mapValue;
-exports.normalizeTwoDigitYear = normalizeTwoDigitYear;
-exports.parseAnyDigitsSigned = parseAnyDigitsSigned;
-exports.parseNDigits = parseNDigits;
-exports.parseNDigitsSigned = parseNDigitsSigned;
-exports.parseNumericPattern = parseNumericPattern;
-exports.parseTimezonePattern = parseTimezonePattern;
-var _index = require("../../constants/index.js");
-var _constants = require("./constants.js");
-function mapValue(parseFnResult, mapFn) {
- if (!parseFnResult) {
- return parseFnResult;
- }
- return {
- value: mapFn(parseFnResult.value),
- rest: parseFnResult.rest
- };
-}
-function parseNumericPattern(pattern, dateString) {
- var matchResult = dateString.match(pattern);
- if (!matchResult) {
- return null;
- }
- return {
- value: parseInt(matchResult[0], 10),
- rest: dateString.slice(matchResult[0].length)
- };
-}
-function parseTimezonePattern(pattern, dateString) {
- var matchResult = dateString.match(pattern);
- if (!matchResult) {
- return null;
- }
-
- // Input is 'Z'
- if (matchResult[0] === 'Z') {
- return {
- value: 0,
- rest: dateString.slice(1)
- };
- }
- var sign = matchResult[1] === '+' ? 1 : -1;
- var hours = matchResult[2] ? parseInt(matchResult[2], 10) : 0;
- var minutes = matchResult[3] ? parseInt(matchResult[3], 10) : 0;
- var seconds = matchResult[5] ? parseInt(matchResult[5], 10) : 0;
- return {
- value: sign * (hours * _index.millisecondsInHour + minutes * _index.millisecondsInMinute + seconds * _index.millisecondsInSecond),
- rest: dateString.slice(matchResult[0].length)
- };
-}
-function parseAnyDigitsSigned(dateString) {
- return parseNumericPattern(_constants.numericPatterns.anyDigitsSigned, dateString);
-}
-function parseNDigits(n, dateString) {
- switch (n) {
- case 1:
- return parseNumericPattern(_constants.numericPatterns.singleDigit, dateString);
- case 2:
- return parseNumericPattern(_constants.numericPatterns.twoDigits, dateString);
- case 3:
- return parseNumericPattern(_constants.numericPatterns.threeDigits, dateString);
- case 4:
- return parseNumericPattern(_constants.numericPatterns.fourDigits, dateString);
- default:
- return parseNumericPattern(new RegExp('^\\d{1,' + n + '}'), dateString);
- }
-}
-function parseNDigitsSigned(n, dateString) {
- switch (n) {
- case 1:
- return parseNumericPattern(_constants.numericPatterns.singleDigitSigned, dateString);
- case 2:
- return parseNumericPattern(_constants.numericPatterns.twoDigitsSigned, dateString);
- case 3:
- return parseNumericPattern(_constants.numericPatterns.threeDigitsSigned, dateString);
- case 4:
- return parseNumericPattern(_constants.numericPatterns.fourDigitsSigned, dateString);
- default:
- return parseNumericPattern(new RegExp('^-?\\d{1,' + n + '}'), dateString);
- }
-}
-function dayPeriodEnumToHours(dayPeriod) {
- switch (dayPeriod) {
- case 'morning':
- return 4;
- case 'evening':
- return 17;
- case 'pm':
- case 'noon':
- case 'afternoon':
- return 12;
- case 'am':
- case 'midnight':
- case 'night':
- default:
- return 0;
- }
-}
-function normalizeTwoDigitYear(twoDigitYear, currentYear) {
- var isCommonEra = currentYear > 0;
- // Absolute number of the current year:
- // 1 -> 1 AC
- // 0 -> 1 BC
- // -1 -> 2 BC
- var absCurrentYear = isCommonEra ? currentYear : 1 - currentYear;
- var result;
- if (absCurrentYear <= 50) {
- result = twoDigitYear || 100;
- } else {
- var rangeEnd = absCurrentYear + 50;
- var rangeEndCentury = Math.floor(rangeEnd / 100) * 100;
- var isPreviousCentury = twoDigitYear >= rangeEnd % 100;
- result = twoDigitYear + rangeEndCentury - (isPreviousCentury ? 100 : 0);
- }
- return isCommonEra ? result : 1 - result;
-}
-function isLeapYearIndex(year) {
- return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
-} \ No newline at end of file
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage