* How to format this type of timestamp
@ 2020-10-03 11:55 Jean Louis
2020-10-03 12:22 ` Eli Zaretskii
0 siblings, 1 reply; 14+ messages in thread
From: Jean Louis @ 2020-10-03 11:55 UTC (permalink / raw)
To: help-gnu-emacs
I would like to format this: (date . "1599712637489") to something
like 2020-10-02 20:06:41.119184+03
Here it works, I get: Saturday, March 24, 2018 6:08:38.010 PM
https://www.epochconverter.com/
That is probably the right time.
Which function should I use, I tried format-time-string, but is not
working.
Jean
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to format this type of timestamp
2020-10-03 11:55 How to format this type of timestamp Jean Louis
@ 2020-10-03 12:22 ` Eli Zaretskii
2020-10-04 4:28 ` Jean Louis
0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2020-10-03 12:22 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Sat, 3 Oct 2020 14:55:10 +0300
> From: Jean Louis <bugs@gnu.support>
>
> I would like to format this: (date . "1599712637489") to something
> like 2020-10-02 20:06:41.119184+03
>
> Here it works, I get: Saturday, March 24, 2018 6:08:38.010 PM
> https://www.epochconverter.com/
>
> That is probably the right time.
>
> Which function should I use, I tried format-time-string, but is not
> working.
Where did you get the value 1599712637489? What is its semantics?
The number of seconds since the epoch is several orders of magnitude
smaller. E.g., this works:
(format-time-string "%c" 1599712637.489)
where I divided the value you provided by 1000.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to format this type of timestamp
2020-10-03 12:22 ` Eli Zaretskii
@ 2020-10-04 4:28 ` Jean Louis
2020-10-04 7:32 ` Eli Zaretskii
2020-10-04 7:47 ` tomas
0 siblings, 2 replies; 14+ messages in thread
From: Jean Louis @ 2020-10-04 4:28 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
* Eli Zaretskii <eliz@gnu.org> [2020-10-03 15:23]:
> > Date: Sat, 3 Oct 2020 14:55:10 +0300
> > From: Jean Louis <bugs@gnu.support>
> >
> > I would like to format this: (date . "1599712637489") to something
> > like 2020-10-02 20:06:41.119184+03
> >
> > Here it works, I get: Saturday, March 24, 2018 6:08:38.010 PM
> > https://www.epochconverter.com/
> >
> > That is probably the right time.
> >
> > Which function should I use, I tried format-time-string, but is not
> > working.
>
> Where did you get the value 1599712637489? What is its semantics?
> The number of seconds since the epoch is several orders of magnitude
> smaller. E.g., this works:
>
> (format-time-string "%c" 1599712637.489)
>
> where I divided the value you provided by 1000.
Thank you, that is what I also search, how did developer made that
number. It is export of SMS from encrypted SMS application named
Silence. Maybe I will get answer soon.
Thank you.
Jean
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to format this type of timestamp
2020-10-04 4:28 ` Jean Louis
@ 2020-10-04 7:32 ` Eli Zaretskii
2020-10-04 7:47 ` tomas
1 sibling, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2020-10-04 7:32 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Sun, 4 Oct 2020 07:28:34 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
>
> > Where did you get the value 1599712637489? What is its semantics?
> > The number of seconds since the epoch is several orders of magnitude
> > smaller. E.g., this works:
> >
> > (format-time-string "%c" 1599712637.489)
> >
> > where I divided the value you provided by 1000.
>
> Thank you, that is what I also search, how did developer made that
> number. It is export of SMS from encrypted SMS application named
> Silence. Maybe I will get answer soon.
Perhaps that application reports time in millisecond units?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to format this type of timestamp
2020-10-04 4:28 ` Jean Louis
2020-10-04 7:32 ` Eli Zaretskii
@ 2020-10-04 7:47 ` tomas
2020-10-04 14:08 ` Jean Louis
1 sibling, 1 reply; 14+ messages in thread
From: tomas @ 2020-10-04 7:47 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 758 bytes --]
On Sun, Oct 04, 2020 at 07:28:34AM +0300, Jean Louis wrote:
> * Eli Zaretskii <eliz@gnu.org> [2020-10-03 15:23]:
[...]
> > Where did you get the value 1599712637489? What is its semantics?
[...]
> > (format-time-string "%c" 1599712637.489)
> >
> > where I divided the value you provided by 1000.
>
> Thank you, that is what I also search, how did developer made that
> number. It is export of SMS from encrypted SMS application named
> Silence. Maybe I will get answer soon.
FWIW timestamps as "milliseconds from UNIX epoch" as an integral type
is one of the traditional Java time representations (these days they
prefer to slap the whole OO abstraction cream cake on top ;-)
So this might well be a Javaism.
Cheers
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to format this type of timestamp
2020-10-04 7:47 ` tomas
@ 2020-10-04 14:08 ` Jean Louis
2020-10-04 15:01 ` tomas
0 siblings, 1 reply; 14+ messages in thread
From: Jean Louis @ 2020-10-04 14:08 UTC (permalink / raw)
To: tomas; +Cc: help-gnu-emacs
* tomas@tuxteam.de <tomas@tuxteam.de> [2020-10-04 10:48]:
> On Sun, Oct 04, 2020 at 07:28:34AM +0300, Jean Louis wrote:
> > * Eli Zaretskii <eliz@gnu.org> [2020-10-03 15:23]:
>
> [...]
>
> > > Where did you get the value 1599712637489? What is its semantics?
>
> [...]
>
> > > (format-time-string "%c" 1599712637.489)
> > >
> > > where I divided the value you provided by 1000.
> >
> > Thank you, that is what I also search, how did developer made that
> > number. It is export of SMS from encrypted SMS application named
> > Silence. Maybe I will get answer soon.
>
> FWIW timestamps as "milliseconds from UNIX epoch" as an integral type
> is one of the traditional Java time representations (these days they
> prefer to slap the whole OO abstraction cream cake on top ;-)
>
> So this might well be a Javaism.
Then I guess, this could be the way to get this type of time:
2020-10-02 20:24:37.664704+03
(format-time-string "%F %T.%6N+03" (/ 1599549641372 1000.0))
If there is anything to improve, let me know.
Thank you.
Jean
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to format this type of timestamp
2020-10-04 14:08 ` Jean Louis
@ 2020-10-04 15:01 ` tomas
2020-10-04 16:59 ` Jean Louis
0 siblings, 1 reply; 14+ messages in thread
From: tomas @ 2020-10-04 15:01 UTC (permalink / raw)
To: Jean Louis; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 489 bytes --]
On Sun, Oct 04, 2020 at 05:08:03PM +0300, Jean Louis wrote:
> * tomas@tuxteam.de <tomas@tuxteam.de> [2020-10-04 10:48]:
[...]
> > So this might well be a Javaism.
>
> Then I guess, this could be the way to get this type of time:
> 2020-10-02 20:24:37.664704+03
>
> (format-time-string "%F %T.%6N+03" (/ 1599549641372 1000.0))
>
> If there is anything to improve, let me know.
If you don't care to be precise about timezones, that might
do the job ;-)
Cheers
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to format this type of timestamp
2020-10-04 15:01 ` tomas
@ 2020-10-04 16:59 ` Jean Louis
2020-10-04 18:41 ` Yuri Khan
0 siblings, 1 reply; 14+ messages in thread
From: Jean Louis @ 2020-10-04 16:59 UTC (permalink / raw)
To: tomas; +Cc: help-gnu-emacs
* tomas@tuxteam.de <tomas@tuxteam.de> [2020-10-04 18:01]:
> On Sun, Oct 04, 2020 at 05:08:03PM +0300, Jean Louis wrote:
> > * tomas@tuxteam.de <tomas@tuxteam.de> [2020-10-04 10:48]:
>
> [...]
>
> > > So this might well be a Javaism.
> >
> > Then I guess, this could be the way to get this type of time:
> > 2020-10-02 20:24:37.664704+03
> >
> > (format-time-string "%F %T.%6N+03" (/ 1599549641372 1000.0))
> >
> > If there is anything to improve, let me know.
>
> If you don't care to be precise about timezones, that might
> do the job ;-)
It looks like time zone is not in that string, I am asking developers
of Silence application about that.
Namely, Silence replaces default Android/Replicant/LineageOS SMS
application and enables encryption, so that network providers cannot
(easily) spy on messages. Yet in sales handling and customer
relationship handling, all messages should be somehow visible or
accessible to future sales managers handling such customers and
new sales.
I hope that Silence developers will answer about the format, and if
it is UTC time.
Thanks.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to format this type of timestamp
2020-10-04 16:59 ` Jean Louis
@ 2020-10-04 18:41 ` Yuri Khan
2020-10-04 19:26 ` tomas
2020-10-05 9:05 ` Jean Louis
0 siblings, 2 replies; 14+ messages in thread
From: Yuri Khan @ 2020-10-04 18:41 UTC (permalink / raw)
To: Jean Louis; +Cc: help-gnu-emacs
On Mon, 5 Oct 2020 at 00:00, Jean Louis <bugs@gnu.support> wrote:
> > If you don't care to be precise about timezones, that might
> > do the job ;-)
>
> It looks like time zone is not in that string, I am asking developers
> of Silence application about that.
Of course it’s not in there. By convention, Unix timestamps count
seconds (or milliseconds, in Java’s case) from the midnight between
1969-12-31 and 1970-01-01 as it happened in the UTC time zone. If a
program produces timestamps that look like Unix timestamps but count
from the midnight as it occurred in a different time zone, that’s a
bug in that program.
format-time-string will automatically adjust it to your local time
zone if you do not pass the optional third argument. If you do, its
value specifies the time zone to adjust to.
I think tomas’s remark was about the fact that you hardcode +03 in
your format string but you let Emacs auto-detect your local time zone.
This can cause an inconsistency if it detects a zone other than +03.
Two better options would be:
a. Let Emacs auto-detect the time zone and use the %Z format specifier
to preserve the detected time zone in the string.
(format-time-string "%F %T.%6N%Z" (/ 1599549641372 1000.0))
⇒ "2020-09-08 14:20:41.371999+07"
b. Pass an explicit time zone. In that case, it does not matter
whether you put that same time zone in the format string or use the %Z
specifier, but using %Z is more robust in the face of future
modifications to the code.
(format-time-string "%F %T.%6N%Z" (/ 1599549641372 1000.0)
(* 7 60 60))
⇒ "2020-09-08 14:20:41.371999+07"
(format-time-string "%F %T.%6N%Z" (/ 1599549641372 1000.0)
(* 3 60 60))
⇒ "2020-09-08 10:20:41.371999+03"
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to format this type of timestamp
2020-10-04 18:41 ` Yuri Khan
@ 2020-10-04 19:26 ` tomas
2020-10-05 9:05 ` Jean Louis
1 sibling, 0 replies; 14+ messages in thread
From: tomas @ 2020-10-04 19:26 UTC (permalink / raw)
To: Yuri Khan; +Cc: help-gnu-emacs, Jean Louis
[-- Attachment #1: Type: text/plain, Size: 645 bytes --]
On Mon, Oct 05, 2020 at 01:41:20AM +0700, Yuri Khan wrote:
> On Mon, 5 Oct 2020 at 00:00, Jean Louis <bugs@gnu.support> wrote:
>
> > > If you don't care to be precise about timezones, that might
> > > do the job ;-)
> >
> > It looks like time zone is not in that string, I am asking developers
> > of Silence application about that.
>
> Of course it’s not in there. By convention, Unix timestamps count
> seconds (or milliseconds, in Java’s case) from the midnight between
> 1969-12-31 and 1970-01-01 as it happened in the UTC time zone [...]
Thanks, Yuri -- you explained it far better than I could have :)
Cheers
-- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to format this type of timestamp
2020-10-04 18:41 ` Yuri Khan
2020-10-04 19:26 ` tomas
@ 2020-10-05 9:05 ` Jean Louis
2020-10-05 10:34 ` tomas
1 sibling, 1 reply; 14+ messages in thread
From: Jean Louis @ 2020-10-05 9:05 UTC (permalink / raw)
To: Yuri Khan; +Cc: help-gnu-emacs
* Yuri Khan <yuri.v.khan@gmail.com> [2020-10-04 21:42]:
> I think tomas’s remark was about the fact that you hardcode +03 in
> your format string but you let Emacs auto-detect your local time zone.
> This can cause an inconsistency if it detects a zone other than +03.
> Two better options would be:
>
> a. Let Emacs auto-detect the time zone and use the %Z format specifier
> to preserve the detected time zone in the string.
>
> (format-time-string "%F %T.%6N%Z" (/ 1599549641372 1000.0))
> ⇒ "2020-09-08 14:20:41.371999+07"
Thank you.
It is not good to hard code in my specific case, and also not good to
assume the default local time zone as messages are coming from various
countries in various time zones, it is not practical that I assume my
local time zone, so I am waiting for the answer from developers of
Silence SMS application, as maybe the time is UTC time, then it will
be alright, then I can convert it properly to PostgreSQL timestamp
with time zone.
Thanks for directions.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to format this type of timestamp
2020-10-05 9:05 ` Jean Louis
@ 2020-10-05 10:34 ` tomas
2020-10-05 12:46 ` Tim Visher
0 siblings, 1 reply; 14+ messages in thread
From: tomas @ 2020-10-05 10:34 UTC (permalink / raw)
To: Jean Louis; +Cc: help-gnu-emacs, Yuri Khan
[-- Attachment #1: Type: text/plain, Size: 1645 bytes --]
On Mon, Oct 05, 2020 at 12:05:40PM +0300, Jean Louis wrote:
> * Yuri Khan <yuri.v.khan@gmail.com> [2020-10-04 21:42]:
> > I think tomas’s remark was about the fact that you hardcode +03 in
> > your format string but you let Emacs auto-detect your local time zone.
> > This can cause an inconsistency if it detects a zone other than +03.
> > Two better options would be:
> >
> > a. Let Emacs auto-detect the time zone and use the %Z format specifier
> > to preserve the detected time zone in the string.
> >
> > (format-time-string "%F %T.%6N%Z" (/ 1599549641372 1000.0))
> > ⇒ "2020-09-08 14:20:41.371999+07"
>
> Thank you.
>
> It is not good to hard code in my specific case, and also not good to
> assume the default local time zone as messages are coming from various
> countries in various time zones, it is not practical that I assume my
> local time zone, so I am waiting for the answer from developers of
> Silence SMS application, as maybe the time is UTC time, then it will
> be alright, then I can convert it properly to PostgreSQL timestamp
> with time zone.
I think you don't need that response. They'd be foolish to have a purely
numerical timestamp be other than "seconds [1] from Epoch, in UTC", where
Epoch is 1970-01-01 (well Mac has Epoch on 1900-01-01: whether that's
foolish is left as an exercise to the reader).
Simply because there's no means to communicate.
Typically when /displaying/ the date to a human reader, you pick this
human reader's timezone (or whatever you guess her timezone is).
Cheers
[1] well, milliseconds in your case. Thank Java for it!
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to format this type of timestamp
2020-10-05 10:34 ` tomas
@ 2020-10-05 12:46 ` Tim Visher
2020-10-05 13:10 ` tomas
0 siblings, 1 reply; 14+ messages in thread
From: Tim Visher @ 2020-10-05 12:46 UTC (permalink / raw)
To: tomas; +Cc: help-gnu-emacs, Jean Louis, Yuri Khan
On Mon, Oct 5, 2020 at 6:36 AM <tomas@tuxteam.de> wrote:
> On Mon, Oct 05, 2020 at 12:05:40PM +0300, Jean Louis wrote:
> > * Yuri Khan <yuri.v.khan@gmail.com> [2020-10-04 21:42]:
> > > I think tomas’s remark was about the fact that you hardcode +03 in
> > > your format string but you let Emacs auto-detect your local time zone.
> > > This can cause an inconsistency if it detects a zone other than +03.
> > > Two better options would be:
> > >
> > > a. Let Emacs auto-detect the time zone and use the %Z format specifier
> > > to preserve the detected time zone in the string.
> > >
> > > (format-time-string "%F %T.%6N%Z" (/ 1599549641372 1000.0))
> > > ⇒ "2020-09-08 14:20:41.371999+07"
> >
> > Thank you.
> >
> > It is not good to hard code in my specific case, and also not good to
> > assume the default local time zone as messages are coming from various
> > countries in various time zones, it is not practical that I assume my
> > local time zone, so I am waiting for the answer from developers of
> > Silence SMS application, as maybe the time is UTC time, then it will
> > be alright, then I can convert it properly to PostgreSQL timestamp
> > with time zone.
>
> I think you don't need that response. They'd be foolish to have a purely
> numerical timestamp be other than "seconds [1] from Epoch, in UTC", where
> Epoch is 1970-01-01 (well Mac has Epoch on 1900-01-01: whether that's
> foolish is left as an exercise to the reader).
>
> Simply because there's no means to communicate.
>
> Typically when /displaying/ the date to a human reader, you pick this
> human reader's timezone (or whatever you guess her timezone is).
>
Isn't time fun? https://yourcalendricalfallacyis.com/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to format this type of timestamp
2020-10-05 12:46 ` Tim Visher
@ 2020-10-05 13:10 ` tomas
0 siblings, 0 replies; 14+ messages in thread
From: tomas @ 2020-10-05 13:10 UTC (permalink / raw)
To: Tim Visher; +Cc: help-gnu-emacs, Jean Louis, Yuri Khan
[-- Attachment #1: Type: text/plain, Size: 225 bytes --]
On Mon, Oct 05, 2020 at 08:46:06AM -0400, Tim Visher wrote:
[...]
> Isn't time fun? https://yourcalendricalfallacyis.com/
Thanks for this one :-)
Definitely. We all were assuming the "simple" Gregorian case.
Cheers
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2020-10-05 13:10 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-03 11:55 How to format this type of timestamp Jean Louis
2020-10-03 12:22 ` Eli Zaretskii
2020-10-04 4:28 ` Jean Louis
2020-10-04 7:32 ` Eli Zaretskii
2020-10-04 7:47 ` tomas
2020-10-04 14:08 ` Jean Louis
2020-10-04 15:01 ` tomas
2020-10-04 16:59 ` Jean Louis
2020-10-04 18:41 ` Yuri Khan
2020-10-04 19:26 ` tomas
2020-10-05 9:05 ` Jean Louis
2020-10-05 10:34 ` tomas
2020-10-05 12:46 ` Tim Visher
2020-10-05 13:10 ` tomas
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 read-only IMAP folder(s) and NNTP newsgroup(s).