Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Date limited to 2020 and 2015 does not work ?!?
Date limited to 2020 and 2015 does not work ?!? [message #30010] Thu, 02 December 2010 21:11 Go to next message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
Hi all,

Playing around with the StrToDate() fonction, I discovered that year 2015 doesn't work at all and after 2020, dates role back to 1900.

Some of us probably are making softwares that will last more than 5 years... so I think this point needs some consideration.

Just like the Year 2000 bug, we have our own Year 2015 and year 2020 BUG Very Happy

Here is the bug in action:

	time = timeConverter.Scan("1/1/14 0:0:1");
	DUMP(time);
	DUMP(time.Get());
	time = timeConverter.Scan("1/1/2015:0:1");
	DUMP(time);
	DUMP(time.Get());
	time = timeConverter.Scan("1/1/15:0:1");
	DUMP(time);
	DUMP(time.Get());
	time = timeConverter.Scan("1/1/16 0:0:1");
	DUMP(time);
	DUMP(time.Get());

	time = timeConverter.Scan("1/1/19 0:0:1");
	DUMP(time);
	time = timeConverter.Scan("1/1/20 0:0:1");
	DUMP(time);
	time = timeConverter.Scan("1/1/21 0:0:1");
	DUMP(time);


Here is the output:
time = 01/01/2014 00:00:01
time.Get() = 63555753601
time = 
time.Get() = -1034058182400
time = 
time.Get() = -1034058182400
time = 01/01/2016 00:00:01
time.Get() = 63618825601
time = 01/01/2019 00:00:01
time = 01/01/1920 00:00:01
time = 01/01/1921 00:00:01

Re: Date limited to 2020 and 2015 does not work ?!? [message #30012 is a reply to message #30010] Thu, 02 December 2010 23:54 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3357
Registered: August 2008
Senior Veteran
Hello Didier

I do not know the type of timeConverter. However doing this:
Time t;
int64 g;
		
StrToDate(t, "1/1/19 0:0:1");
int64 g1 = t.Get(); 
StrToDate(t, "1/1/20 0:0:1");
int64 g2 = t.Get(); 
StrToDate(t, "1/1/21 0:0:1");
int64 g3 = t.Get(); 


I get:

g1 = 63713520000
g2 = 60589296000
g3 = 60620918400


This is not important as using two digits years is very unsafe from 2000 year. Doing this:
Time t;
int64 g;
		
StrToDate(t, "1/1/2019 0:0:1");
int64 g1 = t.Get(); 
StrToDate(t, "1/1/2020 0:0:1");
int64 g2 = t.Get(); 
StrToDate(t, "1/1/2021 0:0:1");
int64 g3 = t.Get(); 


I get:

g1 = 63713520000
g2 = 63745056000
g3 = 63776678400

that looks better Smile.


Best regards
IƱaki
Re: Date limited to 2020 and 2015 does not work ?!? [message #30014 is a reply to message #30010] Fri, 03 December 2010 09:32 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
Didier wrote on Thu, 02 December 2010 21:11

Hi all,

Playing around with the StrToDate() fonction, I discovered that year 2015 doesn't work at all and after 2020, dates role back to 1900.


It's not a bug, it's feature Smile
This part of code (from TimeDate.cpp) causes this behavior:
                case 'y':
                        d.year = n;
                        if(d.year < 20) d.year += 2000; // Check again in 2015....
                        else
                        if(d.year < 100) d.year += 1900;
                        break;


Maybe it is time to change it?
Re: Date limited to 2020 and 2015 does not work ?!? [message #30015 is a reply to message #30010] Fri, 03 December 2010 10:17 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
Yep, I would suggest to remove the fallback completely.
(i.e. 20 is really year 20 A.D., not 1920 or 2020)

I think anybody sane already moved to 4 digit year, and others should finally fix their apps, so why not to force them.
Re: Date limited to 2020 and 2015 does not work ?!? [message #30025 is a reply to message #30015] Fri, 03 December 2010 21:30 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
Hi guys,

Thanks for you're replies.

Well it's the same with 4 digits and I had already seen the limitation to 2020, but the thing that really bothers me is that 2015 does not work at all.

See my previous post.

Re: Date limited to 2020 and 2015 does not work ?!? [message #30026 is a reply to message #30025] Fri, 03 December 2010 22:20 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Hi Didier,

It appears, you have a colon immediately following both of your year 2015 representations. I think you should try to add a space and reformulate the time to the correct form. I did not test it, but maybe you should...

Best regards,

Tom
Re: Date limited to 2020 and 2015 does not work ?!? [message #30027 is a reply to message #30026] Fri, 03 December 2010 23:45 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
Ouupss Embarassed

My eyes must have gotten blind from staring at the screen so late. Because not seeing what was so evident ....

Some rest will do some good to my brain I think.

By the way
ConvertTime timeConverter;


Re: Date limited to 2020 and 2015 does not work ?!? [message #30034 is a reply to message #30015] Sat, 04 December 2010 20:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mr_ped wrote on Fri, 03 December 2010 04:17

Yep, I would suggest to remove the fallback completely.
(i.e. 20 is really year 20 A.D., not 1920 or 2020)

I think anybody sane already moved to 4 digit year, and others should finally fix their apps, so why not to force them.


Actually, it is more about comfort when entering dates into EditDate..
Re: Date limited to 2020 and 2015 does not work ?!? [message #30062 is a reply to message #30034] Mon, 06 December 2010 09:10 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
mirek wrote on Sat, 04 December 2010 20:07

mr_ped wrote on Fri, 03 December 2010 04:17

Yep, I would suggest to remove the fallback completely.
(i.e. 20 is really year 20 A.D., not 1920 or 2020)

I think anybody sane already moved to 4 digit year, and others should finally fix their apps, so why not to force them.


Actually, it is more about comfort when entering dates into EditDate..



Yes, but that should be in "presenter" layer IMHO, it's not related to actual datetime type. So in U++ it should be part of EditDate control right in the UI related code, anything more deeper should work with full year. There's another spot in code where it may be handy, during import of external data. Otherwise I think the time_t and 4 digit string is the only acceptable form to work with date internally.
Re: Date limited to 2020 and 2015 does not work ?!? [message #30063 is a reply to message #30062] Mon, 06 December 2010 10:02 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mr_ped wrote on Mon, 06 December 2010 03:10

mirek wrote on Sat, 04 December 2010 20:07

mr_ped wrote on Fri, 03 December 2010 04:17

Yep, I would suggest to remove the fallback completely.
(i.e. 20 is really year 20 A.D., not 1920 or 2020)

I think anybody sane already moved to 4 digit year, and others should finally fix their apps, so why not to force them.


Actually, it is more about comfort when entering dates into EditDate..



Yes, but that should be in "presenter" layer IMHO, it's not related to actual datetime type. So in U++ it should be part of EditDate control right in the UI related code, anything more deeper should work with full year. There's another spot in code where it may be handy, during import of external data. Otherwise I think the time_t and 4 digit string is the only acceptable form to work with date internally.


Well, you might be right - but that means splitting the Convert for Date/Time into two ('presentation' and 'core')...

Mirek

Previous Topic: HELPER: Value grouping to ValueArray
Next Topic: NEW: generic Toupel grouper
Goto Forum:
  


Current Time: Wed Apr 24 14:12:51 CEST 2024

Total time taken to generate the page: 0.01437 seconds