#time #condition #command-line #command-line-tool #day-week #cron-job #matches

app time-condition

Check whether the current time matches a condition passed via CLI args

1 unstable release

0.1.0 Nov 30, 2023

#1525 in Command line utilities

Download history 3/week @ 2024-02-14 8/week @ 2024-02-21 9/week @ 2024-02-28 2/week @ 2024-03-06 3/week @ 2024-03-13 7/week @ 2024-03-27 17/week @ 2024-04-03 88/week @ 2024-04-10

112 downloads per month

AGPL-3.0

18KB

time-condition

time-condition is a command line utility for checking whether the current time matches a condition. It might be useful to narrow down cases in which a certain action should be performed when running inside a cron job for example.

Installation

Use the package manager cargo to install time-condition.

cargo install time-condition

Usage

# Returns a positive result when run on a Thursday in even iso weeks.
time-condition 'iso_week % 2 == 0 && week_day == 4'
# Same but for Sundays in odd iso weeks.
time-condition 'iso_week % 2 == 1 && week_day == 7'

The expression evaluation is powered by https://docs.rs/evalexpr/latest/evalexpr/, with a few additional time based variables exposed:

  • year: The current year.
  • month: The current month (1..=12).
  • iso_week: The current week in the ISO week-numbering year (1..=53).
  • day: The current day of the month (1..=31).
  • week_day: The day in the week, one-indexed, starting with Monday (1..=7).
  • hour: The current hour (0..=23).
  • minute: The current minute (0..=60).

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

AGPL-3.0

Dependencies

~3MB
~53K SLoC