Subject: bug#71986: closed (Re: bug#71986: RFC: date @ to support ms.)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 09 Jul 2024 12:40:02 +0000

Your bug report

#71986: RFC: date @ to support ms.

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
71986: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71986
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#71986: RFC: date @ to support ms.
From: Paul Eggert <[email-masked]>
To: Richard Neill <[email-masked]>
Cc: [email-masked]
Date: Tue, 9 Jul 2024 14:39:15 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

On 7/9/24 03:19, Richard Neill wrote:

> IP_JSON=$(curl https://whatsmyip.dev/api/ip)
> TS=$(echo $IP_JSON | jq '.ts' -r)
> TS=$(echo "$TS/1000" | bc)
> DATE=$(date --date @$TS)

This is better, as it saves on subprocesses:

IP_JSON=$(curl https://whatsmyip.dev/api/ip)
TS=$(jq -nr "$IP_JSON|.ts")
DATE=$(date -d @$((TS / 1000)))

> Anyway, I don't want to waste everyone's time, so if I haven't convinced 
> you, I'll leave it here, and say thank you very much for your 
> consideration.

You're welcome; closing the bug report.

Subject: RFC: date @ to support ms.
From: Richard Neill <[email-masked]>
To: [email-masked]
Date: Sun, 7 Jul 2024 20:46:45 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

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=[email-masked]'

Perhaps one of these syntaxes might be suitable?

  date --date='@ms1720378861258'
  date --date='@@1720378861258'
  date --epoch-ms --date='@1720378861258'

Thanks very much,

Richard