GNU bug report logs -
#71986
RFC: date @ to support ms.
Previous Next
Reported by: Richard Neill <rn214 <at> cam.ac.uk>
Date: Mon, 8 Jul 2024 03:17:02 UTC
Severity: normal
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 07/07/2024 20:46, Richard Neill wrote:
> Hello,
>
> I've noticed a lot of systems now return the timestamp in milliseconds
> since the epoch, rather than seconds. This means that e.g.
>
> date --date='@1720378861258'
>
> will do something rather unexpected!
>
> May I suggest that it would be nice if date had an input format that
> would let me specify that the value is in ms?
>
> I know we can bodge it with bc, or by injecting the decimal, or trimming
> off the last 3 chars, but that seems inelegant, and requires extra
> thinking (and hence bugs) from the programmer.
> date --date='@1720378861.258'
>
> Perhaps one of these syntaxes might be suitable?
>
> date --date='@ms1720378861258'
> date --date='@@1720378861258'
> date --epoch-ms --date='@1720378861258'
Yes this has some merit, but given we can leverage numfmt
to convert / round, I'm not sure it's warranted. Consider for e.g.:
$ ms2date() { date --date=@$(numfmt --to-unit=1K --round=nearest "$1"); } $ ms2date 1720378861999
Sun 07 Jul 2024 20:01:02 IST
cheers,
Pádraig
This bug report was last modified 1 year and 9 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.