Hi, I've mostly completed the calendar calculation code which for now I've put in a calculator only class named QDateCalculator, i.e. it is not a container for a QDate. Most of the api is standard from QDate and/or KCalendarSystem, but I've made a few changes that will need review.
I've implemented 11 of the CLDR calendars, there's just 4 that I need to find unemcumbered formulas for: the Chinese, Hebrew, Islamic and Persian, but I figure I can add those later. It's more important now to move on to the QLocale changes. The code can be found at https://qt.gitorious.org/~odysseus/qt/odysseus- qtbase/commits/qt5-qdatetime. Other changes included are: * Small clean-ups * Add more validity checks * Store jd as qint64 * Split QDateTimeParser into separate file * Move QLocale format code into new class QDateTimeFormatter, remove QDateTime format code (as previously discussed with Denis) The question now is how devs will access the calculator code. I feel making them use QDateCalculator directly is not a good option, it's awkward and more code than necessary. We could have a class like QLocalDate or QCalendarDate which embeds a QDate, but while useful is still awkward. I'd still prefer a way to access everything via QDate so devs don't have to mess around with extra classes. I've been trying to write simple example code to see how different options would work. Directly using QDateCalculator: QDate myDate = QDate::gregorianDate(2000, 1, 1); QDateCalculator myCalc; int localYear = myCalc.year(myDate); QString localString = QLocale::system().toString(myDate); QDateTimeEdit myEdit(myDate); myCalc.setCalendar(QLocale::HebrewCalendar); int hebrewYear = myCalc.year(); Using a QLocalDate convenience class holding a QDate: QLocalDate myDate; myDate.setDate(QDate::gregorianDate(2000, 1, 1)); int localYear = myDate.year(); QString localString = myDate.toString(); QDateTimeEdit myEdit(myDate.date()); myDate.setCalendar(QLocale::HebrewCalendar); int hebrewYear = myDate.year(); Using new methods directly on QDate: QDate myDate = QDate::gregorianDate(2000,1,1); int localYear = myDate.localYear(); QString localString = QLocale::system().toString(myDate); QDateTimeEdit myEdit(myDate); int hebrewYear = myDate.localYear(QLocale::HebrewCalendar); Using a calendar() method on QDate which returns a QLocalDate for the QDate: QDate myDate = QDate::gregorianDate(2000,1,1); int localYear = myDate.calendar().year(); QString localString = myDate.calendar().toString(); QDateTimeEdit myEdit(myDate); int hebrewYear = myDate.calendar(QLocale::HebrewCalendar).year(); Any preferences? Anyone have suggestions on how they see the api working from a devs point-of-view? Just remember that we can't change the existing QDate methods as there's too much code relying on the current behaviour. Cheers! John. _______________________________________________ Qt5-feedback mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
