Skip to content
Permalink
Browse files

Improve docs about locales for date handling expression functions

  • Loading branch information
Hannes authored and nyalldawson committed Mar 30, 2021
1 parent 9eb172a commit 000f8ee41001e7e9b080baa730cdb29aa3512f50
@@ -6,11 +6,11 @@
"arguments": [
{"arg":"datetime","description":"date, time or datetime value"},
{"arg":"format","description":"String template used to format the string. <table><thead><tr><th>Expression</th><th>Output</th></tr></thead><tr valign=\"top\"><td>d</td><td>the day as number without a leading zero (1 to 31)</td></tr><tr valign=\"top\"><td>dd</td><td>the day as number with a leading zero (01 to 31)</td></tr><tr valign=\"top\"><td>ddd</td><td>the abbreviated localized day name (e.g. 'Mon' to 'Sun')</td></tr><tr valign=\"top\"><td>dddd</td><td>the long localized day name (e.g. 'Monday' to 'Sunday')</td></tr><tr valign=\"top\"><td>M</td><td>the month as number without a leading zero (1-12)</td></tr><tr valign=\"top\"><td>MM</td><td>the month as number with a leading zero (01-12)</td></tr><tr valign=\"top\"><td>MMM</td><td>the abbreviated localized month name (e.g. 'Jan' to 'Dec')</td></tr><tr valign=\"top\"><td>MMMM</td><td>the long localized month name (e.g. 'January' to 'December')</td></tr><tr valign=\"top\"><td>yy</td><td>the year as two digit number (00-99)</td></tr><tr valign=\"top\"><td>yyyy</td><td>the year as four digit number</td></tr></table><p>These expressions may be used for the time part of the format string:</p><table><thead><tr><th>Expression</th><th>Output</th></tr></thead><tr valign=\"top\"><td>h</td><td>the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)</td></tr><tr valign=\"top\"><td>hh</td><td>the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)</td></tr><tr valign=\"top\"><td>H</td><td>the hour without a leading zero (0 to 23, even with AM/PM display)</td></tr><tr valign=\"top\"><td>HH</td><td>the hour with a leading zero (00 to 23, even with AM/PM display)</td></tr><tr valign=\"top\"><td>m</td><td>the minute without a leading zero (0 to 59)</td></tr><tr valign=\"top\"><td>mm</td><td>the minute with a leading zero (00 to 59)</td></tr><tr valign=\"top\"><td>s</td><td>the second without a leading zero (0 to 59)</td></tr><tr valign=\"top\"><td>ss</td><td>the second with a leading zero (00 to 59)</td></tr><tr valign=\"top\"><td>z</td><td>the milliseconds without trailing zeroes (0 to 999)</td></tr><tr valign=\"top\"><td>zzz</td><td>the milliseconds with trailing zeroes (000 to 999)</td></tr><tr valign=\"top\"><td>AP or A</td><td>interpret as an AM/PM time. <i>AP</i> must be either 'AM' or 'PM'.</td></tr><tr valign=\"top\"><td>ap or a</td><td>Interpret as an AM/PM time. <i>ap</i> must be either 'am' or 'pm'.</td></tr></table>"},
{"arg":"language","optional":true,"description":"language (lowercase, two- or three-letter, <a href='https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes'>ISO 639 language code</a>) used to format the date into a custom string"}
{"arg":"language","optional":true,"default":"@qgis_locale","description":"language (lowercase, two- or three-letter, <a href='https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes'>ISO 639 language code</a>) used to format the date into a custom string. By default the currently set-up locale is used."}
],
"examples": [ { "expression":"format_date('2012-05-15','dd.MM.yyyy')", "returns":"'15.05.2012'"},
{ "expression":"format_date('2012-05-15','d MMMM yyyy','fr')", "returns":"'15 mai 2012'"},
{ "expression":"format_date('2012-05-15','dddd')", "returns":"'Tuesday'"},
{ "expression":"format_date('2012-05-15','dddd')", "returns":"'Tuesday', if the current locale is an English variant"},
{ "expression":"format_date('2012-05-15 13:54:20','dd.MM.yy')", "returns":"'15.05.12'"},
{ "expression":"format_date('13:54:20','hh:mm AP')", "returns":"'01:54 PM'"}
]
@@ -2,15 +2,15 @@
"name": "to_date",
"type": "function",
"groups": ["Conversions", "Date and Time"],
"description": "Converts a string into a date object. An optional format string can be provided to parse the string; see <a href='https://doc.qt.io/qt-5/qdate.html#fromString-2'>QDate::fromString</a> for additional documentation on the format.",
"description": "Converts a string into a date object. An optional format string can be provided to parse the string; see <a href='https://doc.qt.io/qt-5/qdate.html#fromString-2'>QDate::fromString</a> or the documentation of the format_date function for additional documentation on the format.",
"arguments": [
{"arg":"string","description":"string representing a date value"},
{"arg":"format","optional":true,"description":"format used to convert the string into a date"},
{"arg":"language","optional":true,"description":"language (lowercase, two- or three-letter, ISO 639 language code) used to convert the string into a date"}
{"arg":"language","optional":true,"default":"@qgis_locale","description":"language (lowercase, two- or three-letter, ISO 639 language code) used to convert the string into a date. By default the currently set-up locale is used."}
],
"examples": [
{ "expression":"to_date('2012-05-04')", "returns":"2012-05-04"},
{ "expression":"to_date('June 29, 2019','MMMM d, yyyy')", "returns":"2019-06-29"},
{ "expression":"to_date('June 29, 2019','MMMM d, yyyy')", "returns":"2019-06-29, if the current locale uses the name 'June' for the sixth month, otherwise an error occurs"},
{ "expression":"to_date('29 juin, 2019','d MMMM, yyyy','fr')", "returns":"2019-06-29"}
]
}
@@ -2,15 +2,15 @@
"name": "to_datetime",
"type": "function",
"groups": ["Conversions", "Date and Time"],
"description": "Converts a string into a datetime object. An optional format string can be provided to parse the string; see <a href='https://doc.qt.io/qt-5/qdate.html#fromString-2'>QDate::fromString</a> and <a href='https://doc.qt.io/qt-5/qtime.html#fromString-1'>QTime::fromString</a> for additional documentation on the format.",
"description": "Converts a string into a datetime object. An optional format string can be provided to parse the string; see <a href='https://doc.qt.io/qt-5/qdate.html#fromString-2'>QDate::fromString</a>, <a href='https://doc.qt.io/qt-5/qtime.html#fromString-1'>QTime::fromString</a> or the documentation of the format_date function for additional documentation on the format.",
"arguments": [
{"arg":"string","description":"string representing a datetime value"},
{"arg":"format","optional":true,"description":"format used to convert the string into a datetime"},
{"arg":"language","optional":true,"description":"language (lowercase, two- or three-letter, ISO 639 language code) used to convert the string into a datetime"}
{"arg":"language","optional":true,"default":"@qgis_locale","description":"language (lowercase, two- or three-letter, ISO 639 language code) used to convert the string into a datetime. By default the currently set-up locale is used."}
],
"examples": [
{ "expression":"to_datetime('2012-05-04 12:50:00')", "returns":"2012-05-04T12:50:00"},
{ "expression":"to_datetime('June 29, 2019 @ 12:34','MMMM d, yyyy @ HH:mm')", "returns":"2019-06-29T12:34"},
{ "expression":"to_datetime('June 29, 2019 @ 12:34','MMMM d, yyyy @ HH:mm')", "returns":"2019-06-29T12:34, if the current locale uses the name 'June' for the sixth month, otherwise an error occurs"},
{ "expression":"to_datetime('29 juin, 2019 @ 12:34','d MMMM, yyyy @ HH:mm','fr')", "returns":"2019-06-29T12:34"}
]
}

0 comments on commit 000f8ee

Please sign in to comment.