hron-ts 0.2.0 → 0.4.0
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 +12 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -847,11 +847,16 @@ function matches(schedule, datetime) {
|
|
|
847
847
|
const untilDate = resolveUntil(schedule.until, datetime);
|
|
848
848
|
if (Temporal.PlainDate.compare(date, untilDate) > 0) return false;
|
|
849
849
|
}
|
|
850
|
-
const
|
|
850
|
+
const timeMatchesWithDst = (times) => times.some((tod) => {
|
|
851
|
+
if (zdt.hour === tod.hour && zdt.minute === tod.minute) return true;
|
|
852
|
+
const t = toPlainTime(tod);
|
|
853
|
+
const resolved = atTimeOnDate(date, t, tz);
|
|
854
|
+
return resolved.epochNanoseconds === datetime.epochNanoseconds;
|
|
855
|
+
});
|
|
851
856
|
switch (schedule.expr.type) {
|
|
852
857
|
case "dayRepeat": {
|
|
853
858
|
if (!matchesDayFilter(date, schedule.expr.days)) return false;
|
|
854
|
-
if (!
|
|
859
|
+
if (!timeMatchesWithDst(schedule.expr.times)) return false;
|
|
855
860
|
if (schedule.expr.interval > 1) {
|
|
856
861
|
const anchorDate = schedule.anchor ? Temporal.PlainDate.from(schedule.anchor) : EPOCH_DATE;
|
|
857
862
|
const dayOffset = daysBetween(anchorDate, date);
|
|
@@ -875,13 +880,13 @@ function matches(schedule, datetime) {
|
|
|
875
880
|
const { interval, days, times } = schedule.expr;
|
|
876
881
|
const dow = date.dayOfWeek;
|
|
877
882
|
if (!days.some((d) => weekdayNameToNumber(d) === dow)) return false;
|
|
878
|
-
if (!
|
|
883
|
+
if (!timeMatchesWithDst(times)) return false;
|
|
879
884
|
const anchorDate = schedule.anchor ? Temporal.PlainDate.from(schedule.anchor) : EPOCH_MONDAY;
|
|
880
885
|
const weeks = weeksBetween(anchorDate, date);
|
|
881
886
|
return weeks >= 0 && weeks % interval === 0;
|
|
882
887
|
}
|
|
883
888
|
case "monthRepeat": {
|
|
884
|
-
if (!
|
|
889
|
+
if (!timeMatchesWithDst(schedule.expr.times)) return false;
|
|
885
890
|
if (schedule.expr.interval > 1) {
|
|
886
891
|
const anchorDate = schedule.anchor ? Temporal.PlainDate.from(schedule.anchor) : EPOCH_DATE;
|
|
887
892
|
const monthOffset = monthsBetweenYM(anchorDate, date);
|
|
@@ -902,7 +907,7 @@ function matches(schedule, datetime) {
|
|
|
902
907
|
return Temporal.PlainDate.compare(date, lastWd) === 0;
|
|
903
908
|
}
|
|
904
909
|
case "ordinalRepeat": {
|
|
905
|
-
if (!
|
|
910
|
+
if (!timeMatchesWithDst(schedule.expr.times)) return false;
|
|
906
911
|
if (schedule.expr.interval > 1) {
|
|
907
912
|
const anchorDate = schedule.anchor ? Temporal.PlainDate.from(schedule.anchor) : EPOCH_DATE;
|
|
908
913
|
const monthOffset = monthsBetweenYM(anchorDate, date);
|
|
@@ -926,7 +931,7 @@ function matches(schedule, datetime) {
|
|
|
926
931
|
return Temporal.PlainDate.compare(date, targetDate) === 0;
|
|
927
932
|
}
|
|
928
933
|
case "singleDate": {
|
|
929
|
-
if (!
|
|
934
|
+
if (!timeMatchesWithDst(schedule.expr.times)) return false;
|
|
930
935
|
const { date: dateSpec } = schedule.expr;
|
|
931
936
|
if (dateSpec.type === "iso") {
|
|
932
937
|
const target = Temporal.PlainDate.from(dateSpec.date);
|
|
@@ -938,7 +943,7 @@ function matches(schedule, datetime) {
|
|
|
938
943
|
return false;
|
|
939
944
|
}
|
|
940
945
|
case "yearRepeat": {
|
|
941
|
-
if (!
|
|
946
|
+
if (!timeMatchesWithDst(schedule.expr.times)) return false;
|
|
942
947
|
if (schedule.expr.interval > 1) {
|
|
943
948
|
const anchorYear = schedule.anchor ? Temporal.PlainDate.from(schedule.anchor).year : EPOCH_DATE.year;
|
|
944
949
|
const yearOffset = date.year - anchorYear;
|