Fedora

glibc 2.27 & periphrastic genitive in date

glibc 2.27 adds the missing support to print dates using the periphrastic genitive form according to your locale, which is available in other libc implementations like BSD libc.

To add support to your locale you should fill a bug like this, and review the date modifiers in translations:

  • %O* – don’t use the periphrastic genitive form according to your locale.
    • %OB: “abril” in the example
    • %Ob: “abr.” in the example
  • %B – full month name according to your locale (it’s for use with a periphrastic genitive form).
    • “d’abril” in the example
  • %b – abbreviated month name according to your locale (it’s for use with a periphrastic genitive form).
    • “d’abr.” in the example
python3
Python 3.6.4 (default, Feb  1 2018, 11:03:59) 
[GCC 8.0.1 20180127 (Red Hat 8.0.1-0.6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from time import gmtime, strftime, mktime
>>> import locale
>>> locale.setlocale(locale.LC_TIME, "ca_ES.utf8")
'ca_ES.utf8'
>>> t = (2018, 4, 21, 20, 19, 18, 1, 48, 0)
>>> t = mktime(t)
>>> strftime("%A, %d %B de %Y a les %H:%M:%S", gmtime(t))
'dissabte, 21 d’abril de 2018 a les 19:19:18'
>>> strftime("%a %d %b de %Y", gmtime(t))
'ds. 21 d’abr. de 2018'
>>> strftime("%OB de %Y", gmtime(t))
'abril de 2018'
>>> strftime("%Ob de %Y", gmtime(t))
'abr. de 2018'
>>> 
Anuncis