Friendly dates customization
Description
Customize the strings used to display 'friendly dates' (e.g. a friendly date might display 'today' by default, but you might want to customize this so that it displays in the user's language of choice).
Discussion
All of the strings used in friendly dates can be customized using the Friendly dates customization property. You can use language and text dictionary tags in the customized strings.
Customizing Strings for Friendly Dates
The strings used for displaying dates in a friendly format can be customized by editing the JSON definition shown below. You can use text dictionary (<a5:t>...</a5:t>) and language (<a5:r>...</a5:r>) tags in the strings.
Customizations must be entered using the JSON format. The templates array in the JSON definition contains the text shown for friendly dates. The {data} placeholder is used to position the date in the string.
The example below shows the default JSON object that defines the friendly date strings.
{ "relative": { "flow": "ltr", "templates": { "before": "{data} ago", "same": { "year": "this year", "month": "this month", "week": "this week", "day": "today", "hour": "this hour", "minute": "now", "second": "now" }, "after": "in {data}" } }, "calendar": { "abbreviated": { "templates": { "last": "last {data}", "yesterday": "yesterday {data}", "today": "today {data}", "tomorrow": "tomorrow {data}", "next": "next {data}", "weekFrom": "week from {data}" }, "formats": { "time": "h:0ma", "day": "Wd", "month": "t\\he x", "year": "x of Mon", "longer": "Mon yyyy" } }, "standard": { "templates": { "last": "last {data}", "yesterday": "yesterday {data}", "today": "today {data}", "tomorrow": "tomorrow {data}", "next": "next {data}", "weekFrom": "week from {data}" }, "formats": { "time": "h:0mam", "day": "Weekday", "month": "Wd t\\he x", "year": "Wd t\\he x of Mon", "longer": "Wd t\\he x of Mon yyyy" } }, "extended": { "templates": { "last": "last {data}", "yesterday": "yesterday {data}", "today": "today {data}", "tomorrow": "tomorrow {data}", "next": "next {data}", "weekFrom": "week from {data}" }, "formats": { "time": "h:0mam", "day": "Weekday", "month": "Weekday t\\he x", "year": "Weekday t\\he x of Month", "longer": "Weekday t\\he x of Month yyyy" } } } }
The other properties in the JSON definition are described below:
- Property
- Description
- flow
The text flow direction. Default is "ltr" (left to right).
- formats
The date format for the data. See Date and Time Format Elements for more information about date formats.
See Also