* can zsh / strftime do "date math"?
@ 2011-10-17 5:36 TJ Luoma
2011-10-17 7:15 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: TJ Luoma @ 2011-10-17 5:36 UTC (permalink / raw)
To: Zsh Users
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"
I can also use the various '%' arguments to format the output, like so
gdate --date "+ 17 hours 14 minutes 06 seconds" '+%Y%m%d'`
I'm wondering if there's any way of doing the same thing with zsh.
TjL
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: can zsh / strftime do "date math"?
2011-10-17 5:36 can zsh / strftime do "date math"? TJ Luoma
@ 2011-10-17 7:15 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2011-10-17 7:15 UTC (permalink / raw)
To: Zsh Users
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-10-17 7:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-17 5:36 can zsh / strftime do "date math"? TJ Luoma
2011-10-17 7:15 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).