Date/Time Localization
Overview
You can use Date/Time values as input data for chart, moreover - you can localize input data format so you don't have to reformat it before setting data to XML.
Date/Time Input Localization
A typical XML for Date/Time Input Localization looks this way:
<date_time_format week_starts_from_monday="True">
<months>
<names>January,February,March,April,May,June,Juky,August,September,October,November,December</names>
<short_names>Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec</short_names>
</months>
<time am_string="AM" short_am_string="A" pm_string="PM" short_pm_string="P" />
<week_days>
<names>Sunday,Monday,Tuesday,wednesday,Thursday,Friday,Saturday</names>
<short_names>Su,Mo,Tu,We,Th,Fr,Sa</short_names>
</week_days>
<format>
<full>%yyyy%MM%dd%hh%mm%ss</full>
<date>%yyyy%MM%dd</date>
<time>%hh%mm%ss</time>
</format>
</date_time_format>
</locale>
So here's an explanation. date_time_format is the chief node of localization. It has a single attribute: week_starts_from_monday. If it is set to "True", the days of the week will start from monday, if "False" - then from Sunday. Also our main node has 4 subnodes: months, time, week_days and format.
The node that is defining short and usual month names is months. names subnode contains the regular month names, as short_names defines brief names. The values go starting from January to December and are splitted by comma. You will need all these names later while formatting.
time node defines how full and short AM and PM times should be defined. So the attributes are: am_string, short_am_string, pm_string, short_pm_string.
week_days node goes by analogy with months node. names and short_names include full and short names of week days, starting from Sunday.
Date/Time Formatting
Now let's let's create a Project Gantt Chart using Date/Time Formatting. Our actual_start and actual end periods will be set using full date/time format (from years to seconds), all periods will be separated by dots. So the only task's XML looks like this:
And XML for date/time formatting:
<locale>
<date_time_format week_starts_from_monday="True">
<months>
<names>January,February,March,April,May,June,July,August,September,October,November,December</names>
<short_names>Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec</short_names>
</months>
<time am_string="AM" short_am_string="A" pm_string="PM" short_pm_string="P" />
<week_days>
<names>Sunday,Monday,Tuesday,wednesday,Thursday,Friday,Saturday</names>
<short_names>Su,Mo,Tu,We,Th,Fr,Sa</short_names>
</week_days>
<format>
<full>%yyyy.%MM.%dd.%HH.%mm.%ss</full>
<date>%yyyy.%MM.%dd</date>
<time>%HH.%mm.%ss</time>
</format>
</date_time_format>
</locale>
</settings>
Note that before every date sign we used "%" prefix. Full list of date/time keywords look at the end of this article
.![]() |
Date/Time Keywords
All formatting parameters for keyword are specified in a following way: {%KeywordName}{Param:value} or, if you need to specify several parameters: {%KeywordName}{Param1:Value1,Param2:Value2}, note that all keywords, parameters and parameter values are case-sensitive.
If you want to use these symbols ":", "{", "}" , "," in parameter format use "\:", "\{", "\}" , "\," instead.
By default all datetime keywords are formatted, to disable formatting use {%KeywordName}{enabled:False}
Formatting Parameters List
Format specifier | Description |
---|---|
%d | Displays the current day of the month, measured as a number between 1 and 31, inclusive. If the day is a single digit only (1-9), then it is displayed as a single digit. |
%dd | Displays the current day of the month, measured as a number between 1 and 31, inclusive. If the day is a single digit only (1-9), it is formatted with a preceding 0 (01-09). |
%ddd | The abbreviated name of the day of the week. |
%dddd | The full name of the day of the week. |
%M | Displays the month, measured as a number between 1 and 12, inclusive. If the month is a single digit (1-9), it is displayed as a single digit. |
%MM | Displays the month, measured as a number between 1 and 12, inclusive. If the month is a single digit (1-9), it is formatted with a preceding 0 (01-09). |
%MMM | The abbreviated name of the month. |
%MMMM | The full name of the month. |
%y | Displays the year as a maximum two-digit number. The first two digits of the year are omitted. If the year is a single digit (1-9), it is displayed as a single digit. |
%yy | Displays the year as a maximum two-digit number. The first two digits of the year are omitted. If the year is a single digit (1-9), it is formatted with a preceding 0 (01-09). |
%yyyy | Displays the year, including the century. If the year is less than four digits in length, then preceding zeros are appended as necessary to make the displayed year four digits long. |
%h | Displays the hour in the range 1-12. The hour represents whole hours passed since either midnight (displayed as 12) or noon (also displayed as 12). If the hour is a single digit (1-9), it is displayed as a single digit. No rounding occurs when displaying the hour. |
%hh | Displays the hour in the range 1-12. The hour represents whole hours passed since either midnight (displayed as 12) or noon (also displayed as 12). If the hour is a single digit (1-9), it is formatted with a preceding 0 (01-09). |
%H | Displays the hour in the range 0-23. The hour represents whole hours passed since midnight (displayed as 0). If the hour is a single digit (0-9), it is displayed as a single digit. |
%HH | Displays the hour in the range 0-23. The hour represents whole hours passed since midnight (displayed as 0). If the hour is a single digit (0-9), it is formatted with a preceding 0 (01-09). |
%m | Displays the minute in the range 0-59. The minute represents whole minutes passed since the last hour. If the minute is a single digit (0-9), it is displayed as a single digit. |
%mm | Displays the minute in the range 0-59. The minute represents whole minutes passed since the last hour. If the minute is a single digit (0-9), it is formatted with a preceding 0 (01-09). |
%s | Displays the seconds in the range 0-59. The second represents whole seconds passed since the last minute. If the second is a single digit (0-9), it is displayed as a single digit only. |
%ss | Displays the seconds in the range 0-59. The second represents whole seconds passed since the last minute. If the second is a single digit (0-9), it is formatted with a preceding 0 (01-09). |
%t | Short am/pm name. |
%tt | The first character in the AM/PM designator. |
%z | Displays the time zone offset for the system's current time zone in whole hours only. The offset is always displayed with a leading sign (zero is displayed as "+0"), indicating hours ahead of Greenwich mean time (+) or hours behind Greenwich mean time (-). The range of values is –12 to +13. If the offset is a single digit (0-9), it is displayed as a single digit with the appropriate leading sign. The setting for the time zone is specified as +X or –X where X is the offset in hours from GMT. The displayed offset is affected by daylight savings time. |
%zz | Displays the time zone offset for the system's current time zone in whole hours only. The offset is always displayed with a leading or trailing sign (zero is displayed as "+00"), indicating hours ahead of Greenwich mean time (+) or hours behind Greenwich mean time (-). The range of values is –12 to +13. If the offset is a single digit (0-9), it is formatted with a preceding 0 (01-09) with the appropriate leading sign. The setting for the time zone is specified as +X or –X where X is the offset in hours from GMT. The displayed offset is affected by daylight savings time. |
%zzz | Displays the time zone offset for the system's current time zone in hours and minutes. The offset is always displayed with a leading or trailing sign (zero is displayed as "+00:00"), indicating hours ahead of Greenwich mean time (+) or hours behind Greenwich mean time (-). The range of values is –12:00 to +13:00. If the offset is a single digit (0-9), it is formatted with a preceding 0 (01-09) with the appropriate leading sign. The setting for the time zone is specified as +X or –X where X is the offset in hours from GMT. The displayed offset is affected by daylight savings time. |