|
| From: | Tapani Tarvainen |
| Subject: | Re: EPOCHREALTIME to days, hours, minutes, seconds |
| Date: | Fri, 20 Aug 2021 16:34:20 +0300 |
On Fri, Aug 20, 2021 at 12:22:21PM +0000, hancooper (hancooper@protonmail.com)
wrote:
> > now=$EPOCHSECONDS
> > printf -v seconds '%(%S)T' "$now"
> > printf -v minutes '%(%M)T' "$now"
> > printf -v hours '%(%H)T' "$now"
> How can I deal with seconds that includes fractional part ?
The Gnu date -based solution I posted earlier deals with them,
but the above can be modified to do it as well:
now=$EPOCHREALTIME
printf -v seconds "%(%S)T.${now#*.}" "${now%.*}"
printf -v minutes '%(%M)T' "${now%.*}"
printf -v hours '%(%H)T' "${now%.*}"
--
Tapani Tarvainen
| [Prev in Thread] | Current Thread | [Next in Thread] |