Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggestion: option to specify date/time #16

Open
dicktyr opened this issue Feb 9, 2021 · 1 comment
Open

suggestion: option to specify date/time #16

dicktyr opened this issue Feb 9, 2021 · 1 comment

Comments

@dicktyr
Copy link

dicktyr commented Feb 9, 2021

considering the Pareto distribution in my own crontab
(i.e. most of the jobs run at a specific time of day)
I suggest an option to compactly specify time and/or date
(perhaps -h for human)

snooze -h 11:51 -> snooze -H 11 -M 51
snooze -h "Feb 9" -> snooze -m 2 -d 9
snooze -h "Feb 9 11:51:37" -> snooze -m 2 -d 9 -H 11 -M 51 -S 37

it seems reasonable to expect ordered input
(i.e. big to small: month day hour:minute:second)
and each unit can be easily parsed with the usual syntax
(alternation, range, star, repetition)

snooze -h string
string -> date time | date | time
date -> month d | month | d
month -> $(date +%b)*
time -> H:M | H:M:S

* also useful to allow date +%a for option -w and date +%b for option -m
date +%a -> locale's abbreviated weekday name (e.g., Sun)
date +%b -> locale's abbreviated month name (e.g., Jan)

@Earnestly
Copy link

For such a tool it may be reasonable to use things like GNU date's -d flag to synthesise the snooze command-line.

In one such script I do this to expose the date string to the user with the following:

# In bash you could use process substitution:
# read -r w h m s < <(date -d "$date" +'-w%w -H%H -M%M -S%S')
# snooze -v "$w" "$h" "$m" "$s"

date -d "$date" +'-w%w -H%H -M%M -S%S' | {
    read -r w h m s

    if snooze -v "$w" "$h" "$m" "$s"; then
        ...
    fi
}

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

No branches or pull requests

2 participants