Skip to content

Modulo extension weeks change on Wednesday #114

Description

@hughkelsey

Issue description

When scheduling a cron to run every other week using the Modulo operator the even/odd week switches between Tuesday and Wednesday rather than Saturday and Sunday. This may in fact be an issue within EtOrbi but I'm seeing it with my cron parsing.

It would be expected that the jobs below would all run every other week on Monday and Wednesday however they actually run one week on Monday and the next week on Wednesday.
0 12 * * 1%2+1,3%2+1
0 12 * * 3%2+1
0 12 * * 1%2+1

In contrast 0 12 * * 3%2+1,4%2+1 runs every other Wed/Thursday in the same week.

How to reproduce

require 'fugit'
Date.today # "2025-09-25"
Fugit.parse_cron("0 12 * * 1%2+1,3%2+1").next.take(6).map(&:to_s).each {puts it}
# 2025-10-01 12:00:00 +0000
# 2025-10-06 12:00:00 +0000
# 2025-10-15 12:00:00 +0000
# 2025-10-20 12:00:00 +0000
# 2025-10-29 12:00:00 +0000
# 2025-11-03 12:00:00 +0000

Expected behaviour

I would expect the Monday and Wednesday to fall within the same week
2025-09-29 12:00:00 +0000
2025-10-01 12:00:00 +0000
2025-10-12 12:00:00 +0000
2025-10-15 12:00:00 +0000

This is possibly from the EtOrbi reference date 2019-01-01 being a Tuesday rather than a Sunday.

Context

Darwin Mac.home.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:51 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T8112 arm64
ruby 3.4.2 (2025-02-15 revision d2930f8e7a) +PRISM [arm64-darwin24]
[:env_tz, nil]
(secs:1758837896.222628,utc~:"2025-09-25 22:04:56.22262811660766602",ltz~:"PDT")
(etz:nil,tnz:"PDT",tziv:"2.0.6",tzidv:"1.2024.2",rv:"3.4.2",rp:"arm64-darwin24",win:false,rorv:nil,astz:nil,chronic:nil,eov:"1.3.0",eotnz:#<TZInfo::TimezoneProxy: America/Ensenada>,eotnfz:"-0700",eotlzn:"America/Ensenada",eotnfZ:"PDT",debian:nil,centos:nil,osx:"zoneinfo/America/Vancouver")
[:et_orbi, "1.3.0"]
[:fugit, "1.11.1"]
[:now, 2025-09-25 15:04:57.115353 -0700, :zone, "PDT"]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions