[Qt-interest] QDateEdit minimum date is year 100

John Layt johnlayt at googlemail.com
Wed Mar 10 18:55:43 CET 2010


On Wednesday 10 Mar 2010 16:30:21 Maximilien Renard wrote:
> Hi there,
> 
> I'm currently developing a electronic patient record managing program and
> I've stumbled upon a quite annoying problem.
> 
> QDateEdit allows a minimum date only back to the 100-01-01. I've checked
> the Qt bug tracker and found an issue about this problem that was closed.
> It was said that Qt developers would take a look at this for the release
> of Qt 5.0
> 
> After having checked, I found that QDate lets us input any kind of dates
> (including negative years).
> 
> It seems that the issue is difficult to fix since they plan to look at this
> only with the release 5.0 (when is that planned btw ?) but couldn't it be
> possible to make the QDateEdit display 0000-00-00 when a any date below
> 100-01-01 is given and return an invalid or null date when calling date() ?
> Although I haven't checked the source code of Qt yet, it doesn't seem to me
> that this should be that difficult. It would be a quick but very useful fix
> for people using databases (like me :P) since the date 0000-00-00 is used
> as the null date (with MySQL at least).
> 
>  My questions are the following : 1) What do you think about this idea ? 2)
> I'm not familiar with bug tracker, should I create a new issue to make this
> suggestion or is this the place to do it (in which case there would be
> nothing else to do but wait for an answer :) ) ?
> 
> Thank you very much for your future answers,
> 
> 
> Kind regards,
> 
> 
> Maximilien Renard
> ULB - MA1 Ingénieur Civil Biomédical
> maximilien.renard at ulb.ac.be

Interesting, what bug number was this so I can have a read?

I suspect the problem with QDateEdit is that the historic behaviour for the 
now deprecated QDate::setYMD() is that 2 digit years are translated as meaning 
1900-1999, whereas QDate::setDate() takes the year exactly.  So rather than 
being technically hard, it's probably the backwards-compatible guarantee 
that's causing the issue?

Can you clarify exactly why the current behaviour causes you a problem, do you 
want your users to be able to enter invalid or null dates?  I can see a reason 
for null dates, in which case the more obvious option would be to allow a 
blank entry rather than 0000-00-00, especially given that you can set 
different date formats for input that may not so neatly have 0 equivalent?

Cheers!

John.




More information about the Qt-interest-old mailing list