PDA

View Full Version : Extending QDate, QTime and QDateTime



jamadagni
23rd March 2006, 14:41
Dear all,

I have been trying to modify the qdatetime* files to the following ends:


Push the earliest date back to -4000 Jan 01 from a meaningless 1752 date
Allow the client programmer to read the internal representation in milliseconds of QTime
Rename QTime::mds and ds() to something more sensible.
Add a function to return a QTime value as a fraction of a day.
Add a function to return an astronomically valid Julian Day Number from a QDateTime value.


But somehow I am not able to get the stuff to compile correctly. There are too many errors to fit on screen. I have based my modifications on the Qt 4.11 qdatetime* code. Please help me with accomplishing my target successfully.

P.S: Another important matter -- when I modify a GPLed program, the resultant program is copyright me or the original author?

jacek
23rd March 2006, 14:49
Push the earliest date back to -4000 Jan 01 from a meaningless 1752 date
And why "-4000" isn't meaningless? Year 1752 is very important for gregorian calendar.

when I modify a GPLed program, the resultant program is copyright me or the original author?
Both. By removing the Trolltech copyright you have violated GPL licence.

jamadagni
24th March 2006, 02:37
And why "-4000" isn't meaningless? Year 1752 is very important for gregorian calendar.
1582 was the original year of promulgation. See the Wikipedia article. (http://en.wikipedia.org/wiki/Gregorian_calendar) There is no reason why the year of adoption of the calendar in *England* should be used. Why not in another country.

Anyway, -4000 has as much meaning as 8000 has. 8000 is 6000 years ahead of the current important reference point which is year 2000. See:

#define QDATE_INITIAL QDate(2000, 1, 1) in qdatetime_p.h

J2000 is a very very often used astronomical epoch. So if 8000 is 6000 years ahead of 2000, I use -4000 which is 6000 years before 2000. There is much sense here.

Negative years and years before 1752 (or 1582) are also important for astronomical calculations. We would like to use QDateTime for astronomical calculations.


Both. By removing the Trolltech copyright you have violated GPL licence.
OK sorry. Was not clear. I will fix it.

jacek
24th March 2006, 02:54
1582 was the original year of promulgation. See the Wikipedia article. (http://en.wikipedia.org/wiki/Gregorian_calendar) There is no reason why the year of adoption of the calendar in *England* should be used. Why not in another country.
If somebody has British locale set, then I would expect that 1582-10-11 would be a valid date, while with Polish locale it should be invalid. Also I would expect that daysTo() would take into account those missing days.

jamadagni
24th March 2006, 03:16
If somebody has British locale set, then I would expect that 1582-10-11 would be a valid date, while with Polish locale it should be invalid.
No. There also exists the proleptic Gregorian calendar (http://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar) which extends the Gregorian calendar theoretically before its date of creation. This is heavily used by astronomers. (KStars however uses the Julian calendar before 1582-10-15 on the Gregorian. Try finding in KStars Calculator the spring equinox for 1582 and then for 1583.)

Also I would expect that daysTo() would take into account those missing days.
This is not a problem. The number of days from 1582-10-04 on the Julian calendar to 1582-10-15 on the Gregorian calendar is one, and not undefined, but you would be committing the error of mixing calendar systems. The number of days from 1582-10-04 to 1582-10-15 on the proleptic Gregorian calendar is 11, where 1582-10-04 on the proleptic Gregorian calendar would be 1582-09-2x on the Julian Calendar.

jamadagni
24th March 2006, 12:01
Am trying another approach. I will modify the qdatetime.cpp qdatetime.h qdatetime_p.h files only and introduce them into the 4.11 source and compile and install it.

See the licence notice at the top of the files to see what has been changed.

One problem: handling negative years while converting to and from strings is going to be a problem. So wherever you find 1752 in the source file has not yet been converted. Your help in fixing the string conversion is most appreciated.

jacek
24th March 2006, 12:54
proleptic Gregorian [...] Gregorian [...] Julian [...] Gregorian [...] Julian [...] Gregorian [...] proleptic Gregorian [...] proleptic Gregorian [...] Julian
So which one of those three your modified QDateTime uses?

jamadagni
24th March 2006, 13:50
So which one of those three your modified QDateTime uses?
So you have evidently not understood what proleptic Gregorian is. It is not a separate calendar. "proleptic" is intended to mean "extended backwards". It is the same as the Gregorian calendar which we are all using today extended backwards before its date of "creation" on 1582-10-15. My modified class uses the Gregorian calendar, same as the current class. Only, it allows for storage of dates before 1752.

jacek
24th March 2006, 16:51
So you have evidently not understood what proleptic Gregorian is. It is not a separate calendar. "proleptic" is intended to mean "extended backwards".
So why do you distinguish between Gegorian calendar and proleptic Gregorian calendar if it is the same thing? ;)

I guess that there should be something like a "local calendar" that would handle the transition from Julian to Gregorian calendar in locale-dependent manner.

Maybe instead altering Qt sources, that might cause problems when somebody mixes modified and original Qt libraries, you should design your own library that would provide more general date & time handling classes for Qt applications?