GNU bug report logs -
#78096
31.0.50; calendar-iso-to-absolute and %W time string format are inconsistent
Previous Next
To reply to this bug, email your comments to 78096 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78096
; Package
emacs
.
(Sun, 27 Apr 2025 15:30:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ihor Radchenko <yantar92 <at> posteo.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 27 Apr 2025 15:30:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
This bug was originally reported in
https://orgmode.org/list/174544167676.8.6104466990232889732.690779499 <at> publik.slmail.me
Consider the following:
(calendar-gregorian-from-absolute
;; First day of the second week of 2025
(calendar-iso-to-absolute (list 2 1 2025))) ; => 2025-01-06
Now, let's try to format the same date using `format-time-string'
(format-time-string
"%Y-%m-%d W%W"
(encode-time (parse-time-string "2025-01-06 00:00")))
;; => 2025-01-06 W01
As you can see, week numbering is off by 1 between %W and
`calendar-iso-to-absolute', which is unexpected.
I believe that it is a bug.
In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.42, cairo version 1.18.2) of 2025-04-22 built on localhost
Repository revision: a9ace435a341918eae3e01f2941f5bbca04d7795
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101014
System Description: Gentoo Linux
--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78096
; Package
emacs
.
(Sun, 27 Apr 2025 21:06:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 78096 <at> debbugs.gnu.org (full text, mbox):
On Sun, 27 Apr 2025 15:28:43 +0000 Ihor Radchenko <yantar92 <at> posteo.net> wrote:
> Hi,
>
> This bug was originally reported in
> https://orgmode.org/list/174544167676.8.6104466990232889732.690779499 <at> publik.slmail.me
>
> Consider the following:
>
> (calendar-gregorian-from-absolute
> ;; First day of the second week of 2025
> (calendar-iso-to-absolute (list 2 1 2025))) ; => 2025-01-06
>
> Now, let's try to format the same date using `format-time-string'
>
> (format-time-string
> "%Y-%m-%d W%W"
> (encode-time (parse-time-string "2025-01-06 00:00")))
> ;; => 2025-01-06 W01
>
> As you can see, week numbering is off by 1 between %W and
> `calendar-iso-to-absolute', which is unexpected.
>
> I believe that it is a bug.
The doc string of `format-time-string' says:
%U is the week number starting on Sunday, %W starting on Monday,
%V the week number according to ISO 8601.
(format-time-string
"%Y-%m-%d W%V"
(encode-time (parse-time-string "2025-01-06 00:00")))
=> "2025-01-06 W02"
Maybe just starting the week on Monday does not guarantee that the
result is an ISO commercial date?
Steve Berman
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78096
; Package
emacs
.
(Mon, 28 Apr 2025 16:07:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 78096 <at> debbugs.gnu.org (full text, mbox):
Stephen Berman <stephen.berman <at> gmx.net> writes:
> The doc string of `format-time-string' says:
>
> %U is the week number starting on Sunday, %W starting on Monday,
> %V the week number according to ISO 8601.
>
> (format-time-string
> "%Y-%m-%d W%V"
> (encode-time (parse-time-string "2025-01-06 00:00")))
> => "2025-01-06 W02"
That indeed explains it - %W and %V are apparently not the same and
`calendar-iso-to-absolute' is closer to %V.
> Maybe just starting the week on Monday does not guarantee that the
> result is an ISO commercial date?
Unless you see some error I am not seeing here, this is probably not a
bug, but my misunderstanding.
--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78096
; Package
emacs
.
(Mon, 28 Apr 2025 16:44:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 78096 <at> debbugs.gnu.org (full text, mbox):
On Apr 28 2025, Ihor Radchenko wrote:
> Stephen Berman <stephen.berman <at> gmx.net> writes:
>
>> The doc string of `format-time-string' says:
>>
>> %U is the week number starting on Sunday, %W starting on Monday,
>> %V the week number according to ISO 8601.
>>
>> (format-time-string
>> "%Y-%m-%d W%V"
>> (encode-time (parse-time-string "2025-01-06 00:00")))
>> => "2025-01-06 W02"
>
> That indeed explains it - %W and %V are apparently not the same and
> `calendar-iso-to-absolute' is closer to %V.
The difference is that %V is always the same for the whole week, whereas
%V and %W roll over on 01-01 (and use 0 for a partial first week).
$ for y in $(seq 2020 2025); do date -d "$y-01-01" +"%a %U %V %W"; done
Wed 00 01 00
Fri 00 53 00
Sat 00 52 00
Sun 01 52 00
Mon 00 01 01
Wed 00 01 00
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
This bug report was last modified 5 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.