Subject: bug#74841: [PATCH] srfi-19: Fix ~V converter in date->string.

From: Tomas Volf <[email-masked]>
Date: Fri, 24 Jan 2025 17:23:51 +0100

Ludovic Courtès <[email-masked]> writes:

> Hi,
>
> Tomas Volf <[email-masked]> skribis:
>
>> The ~V is supposed to print ISO week number, not a week number.  This
>> commit fixes that.
>>
>> * module/srfi/srfi-19.scm (date-week-number-iso): New procedure taken
>> from the reference implementation.
>> (directives)<#\V>: Use it.
>> * test-suite/tests/srfi-19.test ("date->string ~V"): Add tests taken
>> from the reference test suite.
>
> The manual just reads this:
>
>      ~U     week of year, Sunday first day of week, ‘00’ to
>             ‘52’
>      ~V     week of year, Monday first day of week, ‘01’ to
>             ‘53’
>
> Should it be fixed or clarified?

Definitely, updated to reference the ISO-8601.

>
>> +(define (date-week-number-iso date)
>
> Please add a docstring.

Done.

>
>> +  (let ((convert (λ (lst)
>> +                   (date->string
>> +                    (make-date 0 0 0 0
>> +                               (caddr lst) (cadr lst) (car lst)
>
> Please use ‘match-lambda’.

Yeah that is much nicer.

>
>> +    (with-test-prefix "date->string ~V"
>> +      (pass-if-equal "Thursday, week 53" "53"
>
> If these are from the SRFI-19 spec, could you add a comment to say so?

Good point, done.

> Thanks,
> Ludo’.

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.