Skip to content

Instantly share code, notes, and snippets.

@danypr92
Created July 12, 2018 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danypr92/95ff80e9f499cafb5508a7887a8ab817 to your computer and use it in GitHub Desktop.
Save danypr92/95ff80e9f499cafb5508a7887a8ab817 to your computer and use it in GitHub Desktop.
Genshi Templates and Babel Date format

Tenemos un template que incluye una fecha y la queremos localizada (con: dia de la semana, dia mes).

Template:

La portabilidad de la línea se llevará a cabo ${record.sim_activation_date_localized} de 2:00h a 6:00h de la madrugada.

Código Python:

from babel.dates import format_datetime

sim_activation_date_localized = format_datetime(record.sim_activation_date, "EEEE, dd MMMM", locale=record.party.lang)

Resultado esperado:

La portabilidad de la línea 610913906 se llevará a cabo miércoles, 11 julio de 2:00h a 6:00h de la madrugada.

Existe alguna forma de que se le de el formato a la fecha directamente en el template en Genshi?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment