[docs] [issue38228] Missing documentation on strftime modifier O

Joan report at bugs.python.org
Thu Sep 19 17:51:22 EDT 2019


New submission from Joan <aseques at gmail.com>:

In the documentation at https://docs.python.org/3.9/library/datetime.html#strftime-strptime-behavior there's an omission of one of the modifiers that can be add to the strftime parameters (O and E)


Quoting from  http://man7.org/linux/man-pages/man3/strftime.3.html


    Some conversion specifications can be modified by preceding the
    conversion specifier character by the E or O modifier to indicate
    that an alternative format should be used.  If the alternative format
    or specification does not exist for the current locale, the behavior
    will be as if the unmodified conversion specification were used. (SU)
    The Single UNIX Specification mentions %Ec, %EC, %Ex, %EX, %Ey, %EY,
    %Od, %Oe, %OH, %OI, %Om, %OM, %OS, %Ou, %OU, %OV, %Ow, %OW, %Oy,
    where the effect of the O modifier is to use alternative numeric
    symbols (say, roman numerals), and that of the E modifier is to use a
    locale-dependent alternative representation.


The modifier works as expected for the O modifier returning the values defined in ab_alt_mon and alt_mon from the locale (instead of the ones defined in abmon and mon.
I haven't been able to get any results with the E modifier (might not be yet defined in any locale)

A small snippet of code to see the difference:
    import locale
    from datetime import datetime
    locale.setlocale(locale.LC_ALL, 'ca_AD.utf8')
    locale.setlocale(locale.LC_ALL, 'ca_ES.utf8')
    now = datetime.now() # current date and time
    date_time = now.strftime("|%Ob|%b|||%OB|%B|")
    print("date and time:",date_time)

----------
assignee: docs at python
components: Documentation
messages: 352816
nosy: aseques, docs at python
priority: normal
severity: normal
status: open
title: Missing documentation on strftime modifier O
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38228>
_______________________________________


More information about the docs mailing list