node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = newDateUTC;
/**
* Use instead of `new Date(Date.UTC(...))` to support years below 100 which doesn't work
* otherwise due to the nature of the
* [`Date` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#interpretation_of_two-digit_years.
*
* For `Date.UTC(...)`, use `newDateUTC(...).getTime()`.
*/
function newDateUTC(fullYear, month, day, hour, minute, second, millisecond) {
var utcDate = new Date(0);
utcDate.setUTCFullYear(fullYear, month, day);
utcDate.setUTCHours(hour, minute, second, millisecond);
return utcDate;
}
module.exports = exports.default;

View File

@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = tzIntlTimeZoneName;
/**
* Returns the formatted time zone name of the provided `timeZone` or the current
* system time zone if omitted, accounting for DST according to the UTC value of
* the date.
*/
function tzIntlTimeZoneName(length, date, options) {
var dtf = getDTF(length, options.timeZone, options.locale);
return dtf.formatToParts ? partsTimeZone(dtf, date) : hackyTimeZone(dtf, date);
}
function partsTimeZone(dtf, date) {
var formatted = dtf.formatToParts(date);
for (var i = formatted.length - 1; i >= 0; --i) {
if (formatted[i].type === 'timeZoneName') {
return formatted[i].value;
}
}
}
function hackyTimeZone(dtf, date) {
var formatted = dtf.format(date).replace(/\u200E/g, '');
var tzNameMatch = / [\w-+ ]+$/.exec(formatted);
return tzNameMatch ? tzNameMatch[0].substr(1) : '';
} // If a locale has been provided `en-US` is used as a fallback in case it is an
// invalid locale, otherwise the locale is left undefined to use the system locale.
function getDTF(length, timeZone, locale) {
if (locale && !locale.code) {
throw new Error("date-fns-tz error: Please set a language code on the locale object imported from date-fns, e.g. `locale.code = 'en-US'`");
}
return new Intl.DateTimeFormat(locale ? [locale.code, 'en-US'] : undefined, {
timeZone: timeZone,
timeZoneName: length
});
}
module.exports = exports.default;

View File

@@ -0,0 +1,137 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = tzParseTimezone;
var _index = _interopRequireDefault(require("../tzTokenizeDate/index.js"));
var _index2 = _interopRequireDefault(require("../newDateUTC/index.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var MILLISECONDS_IN_HOUR = 3600000;
var MILLISECONDS_IN_MINUTE = 60000;
var patterns = {
timezone: /([Z+-].*)$/,
timezoneZ: /^(Z)$/,
timezoneHH: /^([+-]\d{2})$/,
timezoneHHMM: /^([+-])(\d{2}):?(\d{2})$/
}; // Parse various time zone offset formats to an offset in milliseconds
function tzParseTimezone(timezoneString, date, isUtcDate) {
var token;
var absoluteOffset; // Empty string
if (!timezoneString) {
return 0;
} // Z
token = patterns.timezoneZ.exec(timezoneString);
if (token) {
return 0;
}
var hours; // ±hh
token = patterns.timezoneHH.exec(timezoneString);
if (token) {
hours = parseInt(token[1], 10);
if (!validateTimezone(hours)) {
return NaN;
}
return -(hours * MILLISECONDS_IN_HOUR);
} // ±hh:mm or ±hhmm
token = patterns.timezoneHHMM.exec(timezoneString);
if (token) {
hours = parseInt(token[2], 10);
var minutes = parseInt(token[3], 10);
if (!validateTimezone(hours, minutes)) {
return NaN;
}
absoluteOffset = Math.abs(hours) * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE;
return token[1] === '+' ? -absoluteOffset : absoluteOffset;
} // IANA time zone
if (isValidTimezoneIANAString(timezoneString)) {
date = new Date(date || Date.now());
var utcDate = isUtcDate ? date : toUtcDate(date);
var offset = calcOffset(utcDate, timezoneString);
var fixedOffset = isUtcDate ? offset : fixOffset(date, offset, timezoneString);
return -fixedOffset;
}
return NaN;
}
function toUtcDate(date) {
return (0, _index2.default)(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
}
function calcOffset(date, timezoneString) {
var tokens = (0, _index.default)(date, timezoneString); // ms dropped because it's not provided by tzTokenizeDate
var asUTC = (0, _index2.default)(tokens[0], tokens[1] - 1, tokens[2], tokens[3] % 24, tokens[4], tokens[5], 0).getTime();
var asTS = date.getTime();
var over = asTS % 1000;
asTS -= over >= 0 ? over : 1000 + over;
return asUTC - asTS;
}
function fixOffset(date, offset, timezoneString) {
var localTS = date.getTime(); // Our UTC time is just a guess because our offset is just a guess
var utcGuess = localTS - offset; // Test whether the zone matches the offset for this ts
var o2 = calcOffset(new Date(utcGuess), timezoneString); // If so, offset didn't change, and we're done
if (offset === o2) {
return offset;
} // If not, change the ts by the difference in the offset
utcGuess -= o2 - offset; // If that gives us the local time we want, we're done
var o3 = calcOffset(new Date(utcGuess), timezoneString);
if (o2 === o3) {
return o2;
} // If it's different, we're in a hole time. The offset has changed, but we don't adjust the time
return Math.max(o2, o3);
}
function validateTimezone(hours, minutes) {
return -23 <= hours && hours <= 23 && (minutes == null || 0 <= minutes && minutes <= 59);
}
var validIANATimezoneCache = {};
function isValidTimezoneIANAString(timeZoneString) {
if (validIANATimezoneCache[timeZoneString]) return true;
try {
new Intl.DateTimeFormat(undefined, {
timeZone: timeZoneString
});
validIANATimezoneCache[timeZoneString] = true;
return true;
} catch (error) {
return false;
}
}
module.exports = exports.default;

View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/** Regex to identify the presence of a time zone specifier in a date string */
var tzPattern = /(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/;
var _default = tzPattern;
exports.default = _default;
module.exports = exports.default;

View File

@@ -0,0 +1,100 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = tzTokenizeDate;
/**
* Returns the [year, month, day, hour, minute, seconds] tokens of the provided
* `date` as it will be rendered in the `timeZone`.
*/
function tzTokenizeDate(date, timeZone) {
var dtf = getDateTimeFormat(timeZone);
return dtf.formatToParts ? partsOffset(dtf, date) : hackyOffset(dtf, date);
}
var typeToPos = {
year: 0,
month: 1,
day: 2,
hour: 3,
minute: 4,
second: 5
};
function partsOffset(dtf, date) {
try {
var formatted = dtf.formatToParts(date);
var filled = [];
for (var i = 0; i < formatted.length; i++) {
var pos = typeToPos[formatted[i].type];
if (pos >= 0) {
filled[pos] = parseInt(formatted[i].value, 10);
}
}
return filled;
} catch (error) {
if (error instanceof RangeError) {
return [NaN];
}
throw error;
}
}
function hackyOffset(dtf, date) {
var formatted = dtf.format(date);
var parsed = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(formatted); // var [, fMonth, fDay, fYear, fHour, fMinute, fSecond] = parsed
// return [fYear, fMonth, fDay, fHour, fMinute, fSecond]
return [parsed[3], parsed[1], parsed[2], parsed[4], parsed[5], parsed[6]];
} // Get a cached Intl.DateTimeFormat instance for the IANA `timeZone`. This can be used
// to get deterministic local date/time output according to the `en-US` locale which
// can be used to extract local time parts as necessary.
var dtfCache = {};
function getDateTimeFormat(timeZone) {
if (!dtfCache[timeZone]) {
// New browsers use `hourCycle`, IE and Chrome <73 does not support it and uses `hour12`
var testDateFormatted = new Intl.DateTimeFormat('en-US', {
hourCycle: 'h23',
timeZone: 'America/New_York',
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
}).format(new Date('2014-06-25T04:00:00.123Z'));
var hourCycleSupported = testDateFormatted === '06/25/2014, 00:00:00' || testDateFormatted === '06/25/2014 00:00:00';
dtfCache[timeZone] = hourCycleSupported ? new Intl.DateTimeFormat('en-US', {
hourCycle: 'h23',
timeZone: timeZone,
year: 'numeric',
month: 'numeric',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
}) : new Intl.DateTimeFormat('en-US', {
hour12: false,
timeZone: timeZone,
year: 'numeric',
month: 'numeric',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
}
return dtfCache[timeZone];
}
module.exports = exports.default;