Favivon - Correção

This commit is contained in:
2026-05-30 19:59:39 -03:00
parent 76ddaa815d
commit d7dfd221f0
32859 changed files with 5459654 additions and 404 deletions
+75
View File
@@ -0,0 +1,75 @@
"use strict";
exports.tzScan = tzScan;
var _index = require("../tzOffset/index.cjs");
/**
* Time interval.
*/
/**
* Time zone change record.
*/
/**
* The function scans the time zone for changes in the given interval.
*
* @param timeZone - Time zone name (IANA or UTC offset)
* @param interval - Time interval to scan for changes
*
* @returns Array of time zone changes
*/
function tzScan(timeZone, interval) {
const changes = [];
const monthDate = new Date(interval.start);
monthDate.setUTCSeconds(0, 0);
const endDate = new Date(interval.end);
endDate.setUTCSeconds(0, 0);
const endMonthTime = +endDate;
let lastOffset = (0, _index.tzOffset)(timeZone, monthDate);
while (+monthDate < endMonthTime) {
// Month forward
monthDate.setUTCMonth(monthDate.getUTCMonth() + 1);
// Find the month where the offset changes
const offset = (0, _index.tzOffset)(timeZone, monthDate);
if (offset != lastOffset) {
// Rewind a month back to find the day where the offset changes
const dayDate = new Date(monthDate);
dayDate.setUTCMonth(dayDate.getUTCMonth() - 1);
const endDayTime = +monthDate;
lastOffset = (0, _index.tzOffset)(timeZone, dayDate);
while (+dayDate < endDayTime) {
// Day forward
dayDate.setUTCDate(dayDate.getUTCDate() + 1);
// Find the day where the offset changes
const offset = (0, _index.tzOffset)(timeZone, dayDate);
if (offset != lastOffset) {
// Rewind a day back to find the time where the offset changes
const hourDate = new Date(dayDate);
hourDate.setUTCDate(hourDate.getUTCDate() - 1);
const endHourTime = +dayDate;
lastOffset = (0, _index.tzOffset)(timeZone, hourDate);
while (+hourDate < endHourTime) {
// Hour forward
hourDate.setUTCHours(hourDate.getUTCHours() + 1);
// Find the hour where the offset changes
const hourOffset = (0, _index.tzOffset)(timeZone, hourDate);
if (hourOffset !== lastOffset) {
changes.push({
date: new Date(hourDate),
change: hourOffset - lastOffset,
offset: hourOffset
});
}
lastOffset = hourOffset;
}
}
lastOffset = offset;
}
}
lastOffset = offset;
}
return changes;
}
+30
View File
@@ -0,0 +1,30 @@
/**
* Time interval.
*/
export interface TZChangeInterval {
/** Start date. */
start: Date;
/** End date. */
end: Date;
}
/**
* Time zone change record.
*/
export interface TZChange {
/** Date time the change occurs */
date: Date;
/** Offset change in minutes */
change: number;
/** New UTC offset in minutes */
offset: number;
}
/**
* The function scans the time zone for changes in the given interval.
*
* @param timeZone - Time zone name (IANA or UTC offset)
* @param interval - Time interval to scan for changes
*
* @returns Array of time zone changes
*/
export declare function tzScan(timeZone: string, interval: TZChangeInterval): TZChange[];
//# sourceMappingURL=index.d.ts.map
+30
View File
@@ -0,0 +1,30 @@
/**
* Time interval.
*/
export interface TZChangeInterval {
/** Start date. */
start: Date;
/** End date. */
end: Date;
}
/**
* Time zone change record.
*/
export interface TZChange {
/** Date time the change occurs */
date: Date;
/** Offset change in minutes */
change: number;
/** New UTC offset in minutes */
offset: number;
}
/**
* The function scans the time zone for changes in the given interval.
*
* @param timeZone - Time zone name (IANA or UTC offset)
* @param interval - Time interval to scan for changes
*
* @returns Array of time zone changes
*/
export declare function tzScan(timeZone: string, interval: TZChangeInterval): TZChange[];
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tzScan/index.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB;IAClB,KAAK,EAAE,IAAI,CAAC;IACZ,gBAAgB;IAChB,GAAG,EAAE,IAAI,CAAC;CACX;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,kCAAkC;IAClC,IAAI,EAAE,IAAI,CAAC;IACX,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,gBAAgB,GACzB,QAAQ,EAAE,CA+DZ"}
+73
View File
@@ -0,0 +1,73 @@
import { tzOffset } from "../tzOffset/index.js";
/**
* Time interval.
*/
/**
* Time zone change record.
*/
/**
* The function scans the time zone for changes in the given interval.
*
* @param timeZone - Time zone name (IANA or UTC offset)
* @param interval - Time interval to scan for changes
*
* @returns Array of time zone changes
*/
export function tzScan(timeZone, interval) {
const changes = [];
const monthDate = new Date(interval.start);
monthDate.setUTCSeconds(0, 0);
const endDate = new Date(interval.end);
endDate.setUTCSeconds(0, 0);
const endMonthTime = +endDate;
let lastOffset = tzOffset(timeZone, monthDate);
while (+monthDate < endMonthTime) {
// Month forward
monthDate.setUTCMonth(monthDate.getUTCMonth() + 1);
// Find the month where the offset changes
const offset = tzOffset(timeZone, monthDate);
if (offset != lastOffset) {
// Rewind a month back to find the day where the offset changes
const dayDate = new Date(monthDate);
dayDate.setUTCMonth(dayDate.getUTCMonth() - 1);
const endDayTime = +monthDate;
lastOffset = tzOffset(timeZone, dayDate);
while (+dayDate < endDayTime) {
// Day forward
dayDate.setUTCDate(dayDate.getUTCDate() + 1);
// Find the day where the offset changes
const offset = tzOffset(timeZone, dayDate);
if (offset != lastOffset) {
// Rewind a day back to find the time where the offset changes
const hourDate = new Date(dayDate);
hourDate.setUTCDate(hourDate.getUTCDate() - 1);
const endHourTime = +dayDate;
lastOffset = tzOffset(timeZone, hourDate);
while (+hourDate < endHourTime) {
// Hour forward
hourDate.setUTCHours(hourDate.getUTCHours() + 1);
// Find the hour where the offset changes
const hourOffset = tzOffset(timeZone, hourDate);
if (hourOffset !== lastOffset) {
changes.push({
date: new Date(hourDate),
change: hourOffset - lastOffset,
offset: hourOffset
});
}
lastOffset = hourOffset;
}
}
lastOffset = offset;
}
}
lastOffset = offset;
}
return changes;
}