Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: can zsh / strftime do "date math"?



On Oct 17,  1:36am, TJ Luoma wrote:
} Subject: can zsh / strftime do "date math"?
}
} I use the 'gdate' program the from the GNU coreutils to do "date math"
} (I don't know if that's the right term or not).
} 
} For example, if I wanted to know the time would be in 17 hours, 14
} minutes, and 6 seconds, I would use
} 
} 	gdate --date "+ 17 hours 14 minutes 06 seconds"

The closest would be:

zmodload zsh/datetime
strftime '%Y%m%d %H:%M:%S' $[EPOCHSECONDS + (17 * 60 + 14) * 60 + 6]

You can also parse datetimes with "strftime -r" but you must include
the year month and day and which must be more recent than 1969/12/12,
so you can't use it to parse "+ 17 hours 14 minutes 06 seconds".



Messages sorted by: Reverse Date, Date, Thread, Author