Subject: bug#78096: closed (Re: bug#78096: 31.0.50; calendar-iso-to-absolute and %W time string format are inconsistent)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 10 May 2025 09:53:02 +0000

Your bug report

#78096: 31.0.50; calendar-iso-to-absolute and %W time string format are inconsistent

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

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

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

Subject: Re: bug#78096: 31.0.50; calendar-iso-to-absolute and %W time string format are inconsistent
From: Eli Zaretskii <[email-masked]>
To: Andreas Schwab <[email-masked]>
Cc: [email-masked], [email-masked], [email-masked]
Date: Sat, 10 May 2025 12:52:14 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Cc: Stephen Berman <[email-masked]>, [email-masked]
> From: Andreas Schwab <[email-masked]>
> Date: Mon, 28 Apr 2025 18:43:18 +0200
> 
> On Apr 28 2025, Ihor Radchenko wrote:
> 
> > Stephen Berman <[email-masked]> 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

AFAIU, this bug report was based on a misunderstanding of the
subtleties of time formats.  I've updated the documentation to
clarify the differences between these formats, and I'm therefore
closing this bug.

Subject: 31.0.50; calendar-iso-to-absolute and %W time string format are inconsistent
From: Ihor Radchenko <[email-masked]>
To: [email-masked]
Date: Sun, 27 Apr 2025 15:28:43 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

This bug was originally reported in
https://orgmode.org/list/[email-masked]

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>