hroptatyr / dateutils

nifty command line date and time utilities; fast date calculations and conversion in the shell
http://www.fresse.org/dateutils/
Other
616 stars 42 forks source link

Question: Can datetest suport multiple conditions #157

Closed mailsanchu closed 10 months ago

mailsanchu commented 10 months ago

I want to test a given date between 2 dates. Currently, I am doing two conditions. Is it possible to combine the two if conditions?

    if datetest today --gt "$current" -i "$f"; then
        if datetest today --lt "$(dateadd "$current" +13d -i "$f" -f "$f")" -i "$f"; then
hroptatyr commented 10 months ago

Hi, no you cannot have multiple conditions on one line but you can use the shell's conjunction operator to do away with a nested if:

$ if datetest today --get "$current" -i "$f" && datetest today --lt "$(...)"; then
  ...
mailsanchu commented 10 months ago

Cool thanks Closing the ticket