Re: difference in seconds between two formatted dates ...
On Sun 24 Dec 2023 at 23:05:53 (+0000), Albretch Mueller wrote:
> On 12/18/23, Max Nikulin <manikulin@gmail.com> wrote:
> > Timestamp format you have chosen is ambiguous.
> >
> > TZ=Europe/Berlin date -d '@1698539400' '+%Y%m%d%H%M%S'
> > 20231029023000
> >
> > TZ=Europe/Berlin date -d '@1698543000' '+%Y%m%d%H%M%S'
> > 20231029023000
> >
> > You had issues with setting time and timezone, so '+%s' may give
> > incorrect results.
>
> Hmm! and one hour difference is not detected, because of the way is
> being parsed. Why would that happen?
Spring forward and fall back—the clocks change, skipping an hour in
spring and repeating an hour in autumn (Northern hemisphere).
> Why would %S be in the range
> second (00..60), instead of (00..59)?:
Leap seconds—see the example already in the thread:
https://lists.debian.org/debian-user/2023/12/msg00976.html
> seks00=1698539400; TZ=Europe/Berlin date -d '@1698539400' '+%Y%m%d%H%M%S'
>
> seks02=1698543000; TZ=Europe/Berlin date -d '@1698543000' '+%Y%m%d%H%M%S'
>
> diff_seks=$(( seks02 - seks00 ))
> echo "// __ \$diff_seks: |$diff_seks|"
>
> https://man7.org/linux/man-pages/man1/date.1.html
> %Y year
> %m month (01..12)
> %d day of month (e.g., 01)
> %H hour (00..23)
> %M minute (00..59)
> %S second (00..60)
Cheers,
David.
Reply to: