[Development] Calendar Systems proposal
lars.knoll at qt.io
Mon Jan 2 10:21:25 CET 2017
I wonder whether we can't keep handling of different calendars completely outside of QDate. Something similar to what we've done with QString/QLocale. So QDate would continue unchanged and only support the standard Gregorian calendar. In addition, we have a QCalendar class, that can be constructed with a different calendar system, and can then return 'localized' date strings, days, months and years for this calendar system.
QString hebrewDateString = c.toString(date);
int hebrewYear = c.year(date);
Maybe one could even integrate this into QLocale, that already provides support for localized month and day names?
On 19/12/16 14:18, "Development on behalf of Soroush Rabiei" <development-bounces+lars.knoll=qt.io at qt-project.org on behalf of soroush.rabiei at gmail.com> wrote:
Can you elaborate on the reasons that prevent any change of that kind in
QDate? Maybe they can be worked around?
According to https://community.kde.org/Policies/Binary_Compatibility_Issues_With_C%2B%2B#The_Do.27s_and_Don.27ts Adding a member to struct
or class is not possible without breaking ABI. On the other hand https://wiki.qt.io/Qt-Version-Compatibility suggests that Qt minor releases are backwards binary and source compatible. So there is no
chance of touching QDate in Qt5 series.
I'm working on a solution to provide calendar functionality without breaking ABI, while considering possibilities for Qt6 (keep minimum effort for converting current, temporary solution to futures Qt6 one). This may fail of course, There are too many details
that need to be discussed. How we are supposed to change underlying calendar without adding information to QDate? Can we add arguments to all methods with a default value? Something like:
qDebug() << d.year(); // prints 2016
qDebug() << d.year(QCalendar::Jalali); // prints 1395
And then force relevant widgets/views to show/edit date and time on a specific calendar system:
de.setCalendarSystem(QCalendar::Hebrew); // Is this possible?
More information about the Development