[Development] Calendar Types

2013-10-17 Thread qtdev
finally, I'm going to update date time classes to support world calendar 
types while keeping the binary compatibility.

here's an overview of the new changes to be done at this level. Please 
review and let me know if something wrong.

#JohnLayt I'd like to specially hear from you.

• The new Qt::CalendarType enumeration which contains Gregorian, Hebrew, 
Islamic, Persian and Hindu

• These QDate methods will get a new parameter of type Qt::CalendarType 
(Gregorian by default):
QDate(int y, int m, int d)
int day() const
int dayOfWeek() const
int dayOfYear() const
int daysInMonth() const
int daysInYear() const
void getDate(int * year, int * month, int * day)
bool setDate(int year, int month, int day)
QString toString(const QString  format) const
QString toString(Qt::DateFormat format = Qt::TextDate) const
int weekNumber(int * yearNumber = 0) const
int year() const
QDate fromString(const QString  string, Qt::DateFormat format = 
Qt::TextDate)
QDate   fromString(const QString  string, const QString  format)
bool isLeapYear(int year)
QString longDayName(int weekday, MonthNameType type = DateFormat)
QString longMonthName(int month, MonthNameType type = DateFormat)
QString shortDayName(int weekday, MonthNameType type = DateFormat)
QString shortMonthName(int month, MonthNameType type = DateFormat)

• These QDateTime methods will get a new parameter of type 
Qt::CalendarType (Gregorian by default):
QString toString(const QString  format) const
QString toString(Qt::DateFormat format = Qt::TextDate) const
QDateTime fromString(const QString  string, Qt::DateFormat format = 
Qt::TextDate)
QDateTime fromString(const QString  string, const QString  format)

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Calendar Types

2013-10-17 Thread John Layt
On 17 October 2013 19:30,  qt...@madagon.com wrote:
 finally, I'm going to update date time classes to support world calendar
 types while keeping the binary compatibility.

 here's an overview of the new changes to be done at this level. Please
 review and let me know if something wrong.

 #JohnLayt I'd like to specially hear from you.

Hi,

QCalendarSystem is on my TODO list for Qt5.3, but there's a series of
steps we need to complete first to get there.

I do have working code for most of the calendar systems at [1], but
while the API is close to what we will use, the formulas are unlikely
to get used now.  This is because the data required for the names
would add 3-5 MB to the QtCore library size which was deemed too much.

We instead decided to use ICU for all our localization, but that ran
into other problems and so that was shelved too.  There's an outline
of the ICU-based api design at [2], but obviously that now needs to be
reviewed.

The design we will now use is for QCalendarSystem (and other locale
code) to be a thin wrapper around each platforms native support, just
like I did for QTimeZone.  I'll be starting on updating the design
next week.

The problem is that before starting on QCalendarSystem we need to
change QLocale to only use the native platform locale code and
database instead of Qt's own.  The biggest part of that is changing
Linux to always use ICU instead.  I have most of the code for that but
it needs more work.

So, once all that is done we can then add QCalendarSystem, after which
we will need to integrate it into QLocale and QDateTime and the
datetime widgets, so a lot of work to do.

The one thing that won't happen is that QDate will start returning
local calendar values, it will only ever return Gregorian dates to
maintain backwards compatible behaviour.  To get local calendar values
you access the calendar via QLocale.

So, for now wait a little and I'll have an updated design ready in a
couple of weeks to be discussed on list before we get started.

Cheers!

John.

[1] 
https://qt.gitorious.org/qt/odysseus-qtbase/commit/9c1b7ec7772ba2ae1da904c4054bd9032836adff
[2] http://qt-project.org/wiki/Qt-5-ICU
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development