KDE Core/QtMerge/QDateTime
The following are proposed additions to Qt's Date/Time support which KDE would like to see to enable dropping of our own Date/Time support, or would help improve Qt's localization under Win/OSX/CLDR.
Date/Time Formats
Goal: To add more date/time to/from string format codes Rationale: Format codes part of standard CLDR, Windows and OSX date formats and localization, so Qt may not be localizing dates to country or users system date/time format. Some are string form of existing Qt api.
QDateTime formats are based on the Unicode CLDR fomats:
However only a sub-set of these are implemented. Qt currently supports the following format codes:
d Day as a number without a leading zero (1 to 31) dd Day as a number with a leading zero (01 to 31) ddd Weekday abbreviated localized name (e.g. 'Mon' to 'Sun'). dddd Weekday long localized name (e.g. 'Monday' to 'Sunday'). M Month as a number without a leading zero (1 to 12) MM Month as a number with a leading zero (01 to 12) MMM Month abbreviated localized name (e.g. 'Jan' to 'Dec'). MMMM Month long localized name (e.g. 'January' to 'December'). yy Year as two digit number (00 to 99) yyyy Year as four digit number. (-9999 to 9999)
h Hour without a leading zero (0 to 23 or 1 to 12 if AM/PM) hh Hour with a leading zero (00 to 23 or 01 to 12 if AM/PM) H 24 Hour without a leading zero (0 to 23) HH 24 Hour with a leading zero (00 to 23) m Minute without a leading zero (0 to 59) mm Minute with a leading zero (00 to 59) s Second without a leading zero (0 to 59) ss Second with a leading zero (00 to 59) z Milliseconds without leading zeroes (0 to 999) zzz Milliseconds with leading zeroes (000 to 999) AP AM/PM uppercase ap AM/PM lowercase t Timezone (for example "CEST")
Note the ddd and dddd formats are not valid CLDR forms, they should be EEE and EEEE instead. The h and hh formats do not exactly match the CLDR definition.
The following CLDR codes are suggested to be supported:
ddddd Day narrow localized name (e.g. 'M' to 'S'). MMMMM Month narrow localized name (e.g. 'J' to 'D'). y Year without a leading zero (1 to 9999)
D (1..3) Day of Year, numeric with or without leading zeros. Matches existing dayOfYear() api.
w (1-2) Week of Year, numeric with or without leading zero. Matches existing weekNumber() api.
Y (1..n) Week year, e.g. for ISO Week Number year week falls in, forms to match y. Matches existing weekNumber() api.
E (1..5) Weekday, abbreviated (e.g. 'Mon'), long (e.g. 'Monday') and narrow (e.g. 'M')
G (1..5) Era localized name, abbreviated (e.g. 'AD'), long (e.g. 'Anno Domini') and narrow (e.g. 'A')
The following CLDR codes may be implemented but are not considered as important:
Q (1..4) Quarter in year, '2', '02', 'Q2' or '2nd Quarter'
W (1) Week of Month, numeric.
F (1) Day of Week In Month, e.g. if today is 2nd Monday in Month = 2
e (1..5) Weekday, localized numeric (1 or 01), abbreviated (e.g. 'Mon'), long (e.g. 'Monday') and narrow (e.g. 'M'). Would require QLocale support for localized week number, i.e. US week as well as ISO week.
The following new api will be required in QDateTime to support the format codes.
enum QDate::NameFormat( NarrowName, ShortName, LongName ) QString QDate::monthName(NameFormat format) QString QDate::weekdayName(NameFormat format) QStringQDate:: eraName(NameFormat format) int QDate::quarter() int QDate::weekOfMonth() int QDate::weekdayInMonth()
Note the month and day name api are already marked for change in Qt5.