New submission from Joan <aseq...@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@python
components: Documentation
messages: 352816
nosy: aseques, docs@python
priority: normal
severity: normal
status: open
title: Missing documentation on strftime modifier O
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to