Skip to content

Nearest weekday to day of month #3

@madstap

Description

@madstap

This is a feature that the quartz cron syntax has.

W (“weekday”) - used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify “15W” as the value for the day-of-month field, the meaning is: “the nearest weekday to the 15th of the month”. So if the 15th is a Saturday, the trigger will fire on Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you specify “1W” as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not ‘jump’ over the boundary of a month’s days. The ‘W’ character can only be specified when the day-of-month is a single day, not a range or list of days.

This definitely seems useful, but needs some hammock time as to what the syntax and semantics should be.

Questions:

  • Should the range {:monday :friday} be hardcoded or should this be configurable?
  • How does this interfere with other features?
    • This seems incompatible with choosing a day of the week.
    • Incompatible with day of month ranges?

Syntax suggestion:

;; The weekday closest to the 15th
[[15 :w]]

;; The weekday closest to the 10th and to the 10th to last day of the month
[#{[10 :w] [-10 :w]}]

;; The 5th through the 10th, and also the weekday closest to the 25th
[#{{5 10} [25 :w]}]

;; Invalid
[#{{1 [10 :w]}}]
[:friday [10 :w]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions