diff --git a/docs/advanced_usage.md b/docs/advanced_usage.md index 763488189..378ad424a 100644 --- a/docs/advanced_usage.md +++ b/docs/advanced_usage.md @@ -469,12 +469,12 @@ The `get_cf_value` filter retrieves a value from custom field data with optional ##### Datetime Formatting -The `format_datetime`filter formats a datetime string or datetime object using Python's strftime formatting. +The `datetime` filter formats a datetime string or datetime object using Python's strftime formatting. ###### Syntax ```jinja2 -{{ datetime_value | format_datetime('%Y-%m-%d %H:%M:%S') }} +{{ datetime_value | datetime('%Y-%m-%d %H:%M:%S') }} ``` ###### Parameters @@ -490,15 +490,11 @@ The `format_datetime`filter formats a datetime string or datetime object using P ```jinja2 -{{ created_at | format_datetime('%B %d, %Y at %I:%M %p') }} +{{ created | datetime('%B %d, %Y at %I:%M %p') }} - -{{ "2024-01-15T14:30:00" | format_datetime('%m/%d/%Y') }} - - -{{ timestamp | format_datetime('%A, %B %d, %Y') }} +{{ custom_fields | get_cf_value('Date Field') | datetime('%A, %B %d, %Y') }} ``` @@ -508,7 +504,8 @@ for the possible codes and their meanings. ##### Date Localization The `localize_date` filter formats a date or datetime object into a localized string using Babel internationalization. -This takes into account the provided locale for translation. +This takes into account the provided locale for translation. Since this must be used on a date or datetime object, +you must access the field directly, i.e. `document.created`. ###### Syntax @@ -531,27 +528,27 @@ This takes into account the provided locale for translation. ```jinja2 -{{ created_date | localize_date('short', 'en_US') }} +{{ document.created | localize_date('short', 'en_US') }} -{{ created_date | localize_date('medium', 'en_US') }} +{{ document.created | localize_date('medium', 'en_US') }} -{{ created_date | localize_date('long', 'en_US') }} +{{ document.created | localize_date('long', 'en_US') }} -{{ created_date | localize_date('full', 'en_US') }} +{{ document.created | localize_date('full', 'en_US') }} -{{ created_date | localize_date('medium', 'fr_FR') }} +{{ document.created | localize_date('medium', 'fr_FR') }} -{{ created_date | localize_date('medium', 'de_DE') }} +{{ document.created | localize_date('medium', 'de_DE') }} -{{ created_date | localize_date('dd/MM/yyyy', 'en_GB') }} +{{ document.created | localize_date('dd/MM/yyyy', 'en_GB') }} ```