feat: support `L` (last day of month) by antonidasyang · Pull Request #396 · node-cron/node-cron · GitHub
Skip to content

feat: support L (last day of month)#396

Merged
merencia merged 1 commit into
node-cron:mainfrom
antonidasyang:anton
Jun 17, 2026
Merged

feat: support L (last day of month)#396
merencia merged 1 commit into
node-cron:mainfrom
antonidasyang:anton

Conversation

@antonidasyang

@antonidasyang antonidasyang commented Feb 7, 2023

Copy link
Copy Markdown
Contributor

Closes #147

Adds support for L (last day of the month) in the day-of-month field, the feature originally proposed here by @antonidasyang. The original commits targeted the v3 JavaScript codebase, which has since been rewritten in TypeScript; this branch reimplements the same feature cleanly on the current code (full credit to @antonidasyang for the proposal and the original PR).

Behavior

  • 0 0 12 L * * runs at 12:00 on the last calendar day of every month (28/29/30/31, leap-year aware).
  • Lowercase l is accepted too.
  • Combinable with explicit days: 0 0 12 15,L * * runs on the 15th and the last day.
  • L is valid only in the day-of-month field; variants like LW and L in other fields are rejected by validation.

Implementation

  • The pattern pipeline keeps L as a literal token instead of coercing it to NaN.
  • A small day-of-month helper resolves the last day and the match, shared by both TimeMatcher.match and the MatcherWalker (so getNextMatch lands on the right day).
  • Validation accepts L in the day-of-month field only.

Tests

  • day-of-month unit tests (last-day resolution + matching, including leap years and 15,L).
  • TimeMatcher match + getNextMatch cases (Jan 31, Feb 28, leap Feb 29, roll-over).
  • Validation cases (valid L/l/15,L, rejected LW and L outside day-of-month).

Full suite green (280 tests), build and lint pass.

Implements the feature requested in node-cron#147, originally proposed by @antonidasyang
in node-cron#396, rebuilt on the current TypeScript codebase.

`L` (or lowercase `l`) in the day-of-month field matches the last calendar day
of each month (28-31, leap-aware), on its own (`0 0 12 L * *`) or combined with
explicit days (`0 0 12 15,L * *`). The token is preserved through the pattern
pipeline and resolved against the real date in both match() and getNextMatch.
Validation accepts `L` only in the day-of-month field and rejects variants such
as `LW`.
@merencia merencia changed the base branch from master to main June 17, 2026 11:46
@merencia merencia changed the title add 'l'/'L' for last day of month feat: support L (last day of month) Jun 17, 2026
@merencia merencia merged commit 1ab9abc into node-cron:main Jun 17, 2026
2 checks passed
merencia added a commit that referenced this pull request Jun 17, 2026
Reflects the day-of-month `L` support added in #396.
merencia added a commit that referenced this pull request Jun 17, 2026
Reflects the day-of-month `L` support added in #396.
@merencia merencia mentioned this pull request Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please add support for L for day

2 participants