Skip to content

Rely on babel to format dates & amounts with currencies

Florent Aide requested to merge bitbucket/merged-pr-48 into branch/default

Created originally on Bitbucket by Houzéfa Abbasbhay

Was already merged in Bitbucket before import, marked as merged by the import user

  • Rely on babel to format dates

    Deprecate format_date in favor of a new format_datetime.

  • Rely on babel to format with currencies

    Deprecate format_amount & format_locale in favor of a new format_currency.

Coverage has not been reduced (in fact slight increase).

Docs have been updated.

Showcase in the changelog (docs & tests contain more examples):

function="format_datetime('2015-08-02 17:05:06', format='full', locale='fr_FR')"
    -> dimanche 2 août 2015 à 17:05:06 Temps universel coordonné

function="format_currency(123456789.4242, 'EUR', locale='fr_FR')"
    -> 123 456 789,42 €

format_date to format_datetime also changes format specifiers as Babel uses a different standard (which to me is much nicer than the POSIX one).

format_currency is simpler. Doesn’t have to branch based on date vs datetime so it simply forwards everything to the babel function. 1 change we provide though for convenience: Make the 2nd argument (currency) optional. When not displaying the currency symbol, no need to provide a currency.

Merge request reports

Loading