Bug in strptime in Python 2.3.3

Holger Joukl Holger.Joukl at LBBW.de
Mon Jun 14 03:46:29 EDT 2004


>I still think there is something missing in the way %w is handled
>(note: it is lower case for weekday)
>
>I'd like to know what is missing in _strptime.py for %w handling
>between pre-python 2.3 and post 2.3?

Andy,
If you want to get closer to pre-python 2.3
behaviour you could modify the patch code I posted. E.g. instead of this

527     if weeknr_set:
            # correct julian to be the given weekday (which defaults to 0)
            julian += weekday - datetime_result.weekday()
            if julian < 1:
                # ignore negative values, stay in the current year
                julian = 1

you might want to do s.th. like

527     if weeknr_set:
            # correct julian to be the given weekday (which defaults to 0)
            julian += weekday - datetime_result.weekday()  + (weekday != 6)
* 7
            ##if julian < 1:
                # ignore negative values, stay in the current year
            ##    julian = 1

This is still different with regard to %U values of 0 (days in the previous
year),
but it seems closer to previous python versions. Then again this might
differ
depending on the C libraries on the machine (?).

You might also want to add a weeknr_set = False in the "elif group_key
== 'j'"-section
to have a given julian day override any week number arguments.

Regards
   Holger

Der Inhalt dieser E-Mail ist vertraulich. Falls Sie nicht der angegebene
Empfänger sind oder falls diese E-Mail irrtümlich an Sie adressiert wurde,
verständigen Sie bitte den Absender sofort und löschen Sie die E-Mail
sodann. Das unerlaubte Kopieren sowie die unbefugte Übermittlung sind nicht
gestattet. Die Sicherheit von Übermittlungen per E-Mail kann nicht
garantiert werden. Falls Sie eine Bestätigung wünschen, fordern Sie bitte
den Inhalt der E-Mail als Hardcopy an.

The contents of this  e-mail are confidential. If you are not the named
addressee or if this transmission has been addressed to you in error,
please notify the sender immediately and then delete this e-mail.  Any
unauthorized copying and transmission is forbidden. E-Mail transmission
cannot be guaranteed to be secure. If verification is required, please
request a hard copy version.





More information about the Python-list mailing list