hron-ts 0.3.2 → 0.4.1

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 CHANGED
@@ -875,11 +875,16 @@ function matches(schedule, datetime) {
875
875
  const untilDate = resolveUntil(schedule.until, datetime);
876
876
  if (import_polyfill.Temporal.PlainDate.compare(date, untilDate) > 0) return false;
877
877
  }
878
- const timeMatches = (times) => times.some((tod) => zdt.hour === tod.hour && zdt.minute === tod.minute);
878
+ const timeMatchesWithDst = (times) => times.some((tod) => {
879
+ if (zdt.hour === tod.hour && zdt.minute === tod.minute) return true;
880
+ const t = toPlainTime(tod);
881
+ const resolved = atTimeOnDate(date, t, tz);
882
+ return resolved.epochNanoseconds === datetime.epochNanoseconds;
883
+ });
879
884
  switch (schedule.expr.type) {
880
885
  case "dayRepeat": {
881
886
  if (!matchesDayFilter(date, schedule.expr.days)) return false;
882
- if (!timeMatches(schedule.expr.times)) return false;
887
+ if (!timeMatchesWithDst(schedule.expr.times)) return false;
883
888
  if (schedule.expr.interval > 1) {
884
889
  const anchorDate = schedule.anchor ? import_polyfill.Temporal.PlainDate.from(schedule.anchor) : EPOCH_DATE;
885
890
  const dayOffset = daysBetween(anchorDate, date);
@@ -903,13 +908,13 @@ function matches(schedule, datetime) {
903
908
  const { interval, days, times } = schedule.expr;
904
909
  const dow = date.dayOfWeek;
905
910
  if (!days.some((d) => weekdayNameToNumber(d) === dow)) return false;
906
- if (!timeMatches(times)) return false;
911
+ if (!timeMatchesWithDst(times)) return false;
907
912
  const anchorDate = schedule.anchor ? import_polyfill.Temporal.PlainDate.from(schedule.anchor) : EPOCH_MONDAY;
908
913
  const weeks = weeksBetween(anchorDate, date);
909
914
  return weeks >= 0 && weeks % interval === 0;
910
915
  }
911
916
  case "monthRepeat": {
912
- if (!timeMatches(schedule.expr.times)) return false;
917
+ if (!timeMatchesWithDst(schedule.expr.times)) return false;
913
918
  if (schedule.expr.interval > 1) {
914
919
  const anchorDate = schedule.anchor ? import_polyfill.Temporal.PlainDate.from(schedule.anchor) : EPOCH_DATE;
915
920
  const monthOffset = monthsBetweenYM(anchorDate, date);
@@ -930,7 +935,7 @@ function matches(schedule, datetime) {
930
935
  return import_polyfill.Temporal.PlainDate.compare(date, lastWd) === 0;
931
936
  }
932
937
  case "ordinalRepeat": {
933
- if (!timeMatches(schedule.expr.times)) return false;
938
+ if (!timeMatchesWithDst(schedule.expr.times)) return false;
934
939
  if (schedule.expr.interval > 1) {
935
940
  const anchorDate = schedule.anchor ? import_polyfill.Temporal.PlainDate.from(schedule.anchor) : EPOCH_DATE;
936
941
  const monthOffset = monthsBetweenYM(anchorDate, date);
@@ -954,7 +959,7 @@ function matches(schedule, datetime) {
954
959
  return import_polyfill.Temporal.PlainDate.compare(date, targetDate) === 0;
955
960
  }
956
961
  case "singleDate": {
957
- if (!timeMatches(schedule.expr.times)) return false;
962
+ if (!timeMatchesWithDst(schedule.expr.times)) return false;
958
963
  const { date: dateSpec } = schedule.expr;
959
964
  if (dateSpec.type === "iso") {
960
965
  const target = import_polyfill.Temporal.PlainDate.from(dateSpec.date);
@@ -966,7 +971,7 @@ function matches(schedule, datetime) {
966
971
  return false;
967
972
  }
968
973
  case "yearRepeat": {
969
- if (!timeMatches(schedule.expr.times)) return false;
974
+ if (!timeMatchesWithDst(schedule.expr.times)) return false;
970
975
  if (schedule.expr.interval > 1) {
971
976
  const anchorYear = schedule.anchor ? import_polyfill.Temporal.PlainDate.from(schedule.anchor).year : EPOCH_DATE.year;
972
977
  const yearOffset = date.year - anchorYear;