Changes in HomepageDocuTimeDisplay
Revision Differences of Revision 3
# Time Display Syntax ¶¶
This page describes the syntax for the time display option in your ¶
[Profile](/profile/edit/). You can customize the way times are displayed ¶
on the page. We basically use the syntax implemented by ¶
[django](http://www.djangoproject.net), but we added two extra options to ¶
nicely display relative dates to today. ¶
¶
¶
## Basic Syntax ¶
This is taken directly from the django docs: ¶
¶
| Format character | Description | Example output ¶
| a | 'a.m.' or 'p.m.' (Note that this is slightly different than PHP's output, because this includes periods to match Associated Press style.) | 'a.m.' ¶
| A | 'AM' or 'PM'. | 'AM' ¶
| b | Month, textual, 3 letters, lowercase. | 'jan' ¶
| d | Day of the month, 2 digits with leading zeros. | '01' to '31' ¶
| D | Day of the week, textual, 3 letters. | 'Fri' ¶
| f | Time, in 12-hour hours and minutes, with minutes left off if they're zero. Proprietary extension. | '1', '1:30' ¶
| F | Month, textual, long. | 'January' ¶
| g | Hour, 12-hour format without leading zeros. | '1' to '12' ¶
| G | Hour, 24-hour format without leading zeros. | '0' to '23' ¶
| h | Hour, 12-hour format. | '01' to '12' ¶
| H | Hour, 24-hour format. | '00' to '23' ¶
| i | Minutes. | '00' to '59' ¶
| j | Day of the month without leading zeros. | '1' to '31' ¶
| l | Day of the week, textual, long. | 'Friday' ¶
| L | Boolean for whether it's a leap year. | True or False ¶
| m | Month, 2 digits with leading zeros. | '01' to '12' ¶
| M | Month, textual, 3 letters. | 'Jan' ¶
| n | Month without leading zeros. | '1' to '12' ¶
| N | Month abbreviation in Associated Press style. Proprietary extension. | 'Jan.', 'Feb.', 'March', 'May' ¶
| O | Difference to Greenwich time in hours. | '+0200' ¶
| P | Time, in 12-hour hours, minutes and 'a.m.'/'p.m.', with minutes left off if they're zero and the special-case strings 'midnight' and 'noon' if appropriate. Proprietary extension. | '1 a.m.', '1:30 p.m.', 'midnight', 'noon', '12:30 p.m.' ¶
| r | RFC 2822 formatted date. | 'Thu, 21 Dec 2000 16:01:07 +0200' ¶
| s | Seconds, 2 digits with leading zeros. | '00' to '59' ¶
| S | English ordinal suffix for day of the month, 2 characters. | 'st', 'nd', 'rd' or 'th' ¶
| t | Number of days in the given month. | 28 to 31 ¶
| T | Time zone of this machine. | 'EST', 'MDT' ¶
| w | Day of the week, digits without leading zeros. | '0' (Sunday) to '6' (Saturday) ¶
| W | ISO-8601 week number of year, with weeks starting on Monday. | 1, 53 ¶
| y | Year, 2 digits. | '99' ¶
| Y | Year, 4 digits. | '1999' ¶
| z | Day of the year. | 0 to 365 ¶
| Z | Time zone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. | -43200 to 43200 ¶
¶
Note that any of this characters can be escaped with a trailing \: `\r` ¶
¶
## Extensions ¶
¶
We added the two extensions ¶
¶
Name| Syntax| Description| Sample Output ¶
----| ------| -----------|-------------- ¶
Natural Day | %ND(alternative) | This will put in 'today','yesterday','tomorrow' if fit, otherwise will use the formatting 'alternative' | `%ND(j.m.y)` will yield: 'tomorrow' or '12.2.08' ¶
Natural Year | %NY(formatting) | This will put in the year with the formatting, or if the year is the current year an empty string | `%NY(.y)` will yield: '' if today is in the same year or '.08' if it is in another ¶
¶
## Examples ¶
¶
This is the formatting I use, note that I escaped 'Uhr', so that it shows up as literal chars ¶
¶
%ND(j.m.y), h:m \U\h\r ¶
¶
This formatting might yield '12.3.08, 12:03 Uhr' or 'yesterday, 13:09 Uhr'. ¶
¶
¶