Jump to content
Nigel Thomas

IsValidDate fails after the Year 9999

Recommended Posts

DateUtils.IsValidDate checks if the Year is <= 9999. This means the test will fail in the year 10000 and forward. Shouldn't it be fixed now, to avoid a new "Millenium Bug" panic?

Share this post


Link to post

Independent of the System.DateUtils functions, I have tested the minimum and maximum value accepted by Delphi to inform a valid date and time, being:

  • Delphi: of course, all should knows it
    • Min: 30/12/1899 12:00 AM
    • Max: 31/12/9999  23:59:59.999
  • TDateTime var using a "double" value directly
    • Min: 01/01/0001    00:00:00.001  =         -693593.00000001   =       693,593 days   = 1900 years
    • Max: 12/31/65535  23:59:59.990  = +669528949.999999940  =  23,920,275 days   = 65,535 years
    • Total: 24,613,868 days   = 67,435 years

then, the limitation is just from Delphi procedure!

 

using TDatePicker (MSWin10 component) =  Min: 01/01/0001  Max: 12/31/9999   = 64bits

using TDateTimePicker                                = Min: 01/01/1601  Max: 12/31/9999   = 32bits

 

NOTE: in function to Date/time, Delphi use "look" just first 4 digits for "years", then, the year "65535" stay as "6553"! here is the limitation!

Edited by programmerdelphi2k
  • Like 1

Share this post


Link to post
5 hours ago, Nigel Thomas said:

DateUtils.IsValidDate checks if the Year is <= 9999. This means the test will fail in the year 10000 and forward. Shouldn't it be fixed now, to avoid a new "Millenium Bug" panic?

No. 

  • Like 1

Share this post


Link to post
3 hours ago, David Heffernan said:

No. 

To elaborate on this correct and concise answer: One should only fix things that a really broken or occur during the life cycle of the software. You simply cannot think of all eventualities - one of them being: will there still be a Delphi compiler in the year 9999? If not, how can I make sure that my code can still be compiled? Are we all gonna die? OMG! Panic! Enter into catatonic state now.

 

To use popular acronyms: This is both YAGNI and KISS.

Share this post


Link to post
11 hours ago, Nigel Thomas said:

DateUtils.IsValidDate checks if the Year is <= 9999.

The underlying reason is the Windows date format being limited to four digits :classic_smile:

Share this post


Link to post
1 hour ago, Sherlock said:

To elaborate on this correct and concise answer: One should only fix things that a really broken or occur during the life cycle of the software. You simply cannot think of all eventualities - one of them being: will there still be a Delphi compiler in the year 9999? If not, how can I make sure that my code can still be compiled? Are we all gonna die? OMG! Panic! Enter into catatonic state now.

 

To use popular acronyms: This is both YAGNI and KISS.

I definitely hope that no Delphi code is running by 9999. I'd be amazed if there were any humans left on the planet when that year comes around.

Share this post


Link to post
1 minute ago, David Heffernan said:

I'd be amazed if there were any humans left on the planet when that year comes around.

Planet of the Firemonkeys?

  • Like 1
  • Haha 3

Share this post


Link to post
10 hours ago, Ian Branch said:

I was there for Y2K.  Not sure I will be around for Y10K... 😉

If there will be any issues in the future, I'm very sure I can fix them the day after :classic_cheerleader:

Share this post


Link to post

Quoting the aforementioned RFC 2550:

Quote

 


   There are a number date comparison problems that are beyond the scope
   of this specification.
   (...)
   3) Continued existence of Earth-centric time periods (year, day,
      etc.) are problematical past the up-coming destruction of the
      solar system (5-10 billion years or so).  The use of atomic-time
      helps some since leap seconds are no longer an issue.
   4) Future standards and methods of synchronization for inter-planetary 
      and inter-galactic time have not been agreed to. 
   5) Survivability of dates past the end of the universe is uncertain. 

 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×