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

Previous Next

Package: guile;

Reported by: Tomas Volf <~@wolfsden.cz>

Date: Thu, 12 Dec 2024 21:05:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Tomas Volf <~@wolfsden.cz>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 74841 <at> debbugs.gnu.org
Subject: bug#74841: [PATCH] srfi-19: Fix ~V converter in date->string.
Date: Fri, 24 Jan 2025 17:23:51 +0100
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi,
>
> Tomas Volf <~@wolfsden.cz> 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.
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 135 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.