Spring is here!
-
Yep, indeed spring has come, and my application knew it. What happened: I build a WinCe application used in stores for making orders, inventories, etc... Note that the devices used have very strict memory limitations so no SQL DB server fits on them, the whole DB system is written in-house. One of the functionalities it has, is when you make an order for a specific day, you see how much was ordered the previous days for each item you order. 4 months passed with only positive feedback, and yesterday I got a call. Super urgent, major bug, the ordered amounts of previous days are all lost. :~ I swollowed, cold sweat started flowing down my back, with fake optimism I tell that stuff probably isn't as bad as the customer lets shine through (hoping that it is just another case of user-mistake. It's really amazing what 'bugs' users can come up with that aren't bugs). Anyway they send me a dump of the problematic DB. Scanning it quickly with my DB-viewer I notice that the data is all there (pfew, already a big relief, no data was lost/corrupted due to a bug). Running the actual application using that DB I indeed see that there doesn't seem to be any data available for previous days (the date for which the order is being made is 31/03/2008). I step through the code and can't see any mistake, it worked for 4+ months and now suddenly it doesn't :confused:. And then it hit me! In the DB we save the dates as the numbers of seconds since 1/1/1970. So, for dates where time doesn't matter, they are saved as e.g. 31/03/2008 00:00:00 (12pm). To find how much was ordered x days before the specific day, we substract x days from that date and look for the ordered amount on that date (if there is any). What was the problem now: This sunday: 30/03/2008 the time is being set 1 hour forward, so it has only 23 hours, this means that using my original code, when I want to see what was ordered 2 days before I calculated: 31/03/2008 00:00:00 - 2days (read 48hours).This however is not the expected 29/03/2008 00:00:00 but due to the hour change: 28/03/2008 23:00:00. So searching ordered amounts for that date resulted in nothing :doh:. Well I must say it was an interesting bug, that had me scratching my head for a little while :)
-
Yep, indeed spring has come, and my application knew it. What happened: I build a WinCe application used in stores for making orders, inventories, etc... Note that the devices used have very strict memory limitations so no SQL DB server fits on them, the whole DB system is written in-house. One of the functionalities it has, is when you make an order for a specific day, you see how much was ordered the previous days for each item you order. 4 months passed with only positive feedback, and yesterday I got a call. Super urgent, major bug, the ordered amounts of previous days are all lost. :~ I swollowed, cold sweat started flowing down my back, with fake optimism I tell that stuff probably isn't as bad as the customer lets shine through (hoping that it is just another case of user-mistake. It's really amazing what 'bugs' users can come up with that aren't bugs). Anyway they send me a dump of the problematic DB. Scanning it quickly with my DB-viewer I notice that the data is all there (pfew, already a big relief, no data was lost/corrupted due to a bug). Running the actual application using that DB I indeed see that there doesn't seem to be any data available for previous days (the date for which the order is being made is 31/03/2008). I step through the code and can't see any mistake, it worked for 4+ months and now suddenly it doesn't :confused:. And then it hit me! In the DB we save the dates as the numbers of seconds since 1/1/1970. So, for dates where time doesn't matter, they are saved as e.g. 31/03/2008 00:00:00 (12pm). To find how much was ordered x days before the specific day, we substract x days from that date and look for the ordered amount on that date (if there is any). What was the problem now: This sunday: 30/03/2008 the time is being set 1 hour forward, so it has only 23 hours, this means that using my original code, when I want to see what was ordered 2 days before I calculated: 31/03/2008 00:00:00 - 2days (read 48hours).This however is not the expected 29/03/2008 00:00:00 but due to the hour change: 28/03/2008 23:00:00. So searching ordered amounts for that date resulted in nothing :doh:. Well I must say it was an interesting bug, that had me scratching my head for a little while :)
Interesting developer experience, but definitely: W R O N G F O R U M! Sorry. :) Nevermind. Maybe I was a bit drastic.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarkemodified on Friday, March 28, 2008 9:16 AM
-
Interesting developer experience, but definitely: W R O N G F O R U M! Sorry. :) Nevermind. Maybe I was a bit drastic.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarkemodified on Friday, March 28, 2008 9:16 AM
ummm getting burned by daylight savings shifts certainly seems like s subtle bug to me.
Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop. -- Matthew Faithfull
-
ummm getting burned by daylight savings shifts certainly seems like s subtle bug to me.
Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop. -- Matthew Faithfull
Uhm, maybe. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Interesting developer experience, but definitely: W R O N G F O R U M! Sorry. :) Nevermind. Maybe I was a bit drastic.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarkemodified on Friday, March 28, 2008 9:16 AM
-
I think you posted your wrong forum message to the wrong forum.
Faith is a fine invention For gentlemen who see; But microscopes are prudent In an emergency! -Emily Dickinson
OK, I've already modified my original reply. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Yep, indeed spring has come, and my application knew it. What happened: I build a WinCe application used in stores for making orders, inventories, etc... Note that the devices used have very strict memory limitations so no SQL DB server fits on them, the whole DB system is written in-house. One of the functionalities it has, is when you make an order for a specific day, you see how much was ordered the previous days for each item you order. 4 months passed with only positive feedback, and yesterday I got a call. Super urgent, major bug, the ordered amounts of previous days are all lost. :~ I swollowed, cold sweat started flowing down my back, with fake optimism I tell that stuff probably isn't as bad as the customer lets shine through (hoping that it is just another case of user-mistake. It's really amazing what 'bugs' users can come up with that aren't bugs). Anyway they send me a dump of the problematic DB. Scanning it quickly with my DB-viewer I notice that the data is all there (pfew, already a big relief, no data was lost/corrupted due to a bug). Running the actual application using that DB I indeed see that there doesn't seem to be any data available for previous days (the date for which the order is being made is 31/03/2008). I step through the code and can't see any mistake, it worked for 4+ months and now suddenly it doesn't :confused:. And then it hit me! In the DB we save the dates as the numbers of seconds since 1/1/1970. So, for dates where time doesn't matter, they are saved as e.g. 31/03/2008 00:00:00 (12pm). To find how much was ordered x days before the specific day, we substract x days from that date and look for the ordered amount on that date (if there is any). What was the problem now: This sunday: 30/03/2008 the time is being set 1 hour forward, so it has only 23 hours, this means that using my original code, when I want to see what was ordered 2 days before I calculated: 31/03/2008 00:00:00 - 2days (read 48hours).This however is not the expected 29/03/2008 00:00:00 but due to the hour change: 28/03/2008 23:00:00. So searching ordered amounts for that date resulted in nothing :doh:. Well I must say it was an interesting bug, that had me scratching my head for a little while :)
Which is why we (enlightented developers) use DateTime rather than integer seconds. It's also why we (enlightented developers) use UTC rather than local time. Problems like you described should not have escaped the twentieth century. Learn from history.
GDavy wrote:
31/03/2008 00:00:00 (12pm).
That's 12AM isn't it? Which brings to mind a third-party product we (my current employer) used which stored time as integer seconds since 1970-01-01 (in UTC), but when only the date was important they stored 12:00 (rather than 00:00) in the time.
-
I think you posted your wrong forum message to the wrong forum.
Faith is a fine invention For gentlemen who see; But microscopes are prudent In an emergency! -Emily Dickinson
-
Yep, indeed spring has come, and my application knew it. What happened: I build a WinCe application used in stores for making orders, inventories, etc... Note that the devices used have very strict memory limitations so no SQL DB server fits on them, the whole DB system is written in-house. One of the functionalities it has, is when you make an order for a specific day, you see how much was ordered the previous days for each item you order. 4 months passed with only positive feedback, and yesterday I got a call. Super urgent, major bug, the ordered amounts of previous days are all lost. :~ I swollowed, cold sweat started flowing down my back, with fake optimism I tell that stuff probably isn't as bad as the customer lets shine through (hoping that it is just another case of user-mistake. It's really amazing what 'bugs' users can come up with that aren't bugs). Anyway they send me a dump of the problematic DB. Scanning it quickly with my DB-viewer I notice that the data is all there (pfew, already a big relief, no data was lost/corrupted due to a bug). Running the actual application using that DB I indeed see that there doesn't seem to be any data available for previous days (the date for which the order is being made is 31/03/2008). I step through the code and can't see any mistake, it worked for 4+ months and now suddenly it doesn't :confused:. And then it hit me! In the DB we save the dates as the numbers of seconds since 1/1/1970. So, for dates where time doesn't matter, they are saved as e.g. 31/03/2008 00:00:00 (12pm). To find how much was ordered x days before the specific day, we substract x days from that date and look for the ordered amount on that date (if there is any). What was the problem now: This sunday: 30/03/2008 the time is being set 1 hour forward, so it has only 23 hours, this means that using my original code, when I want to see what was ordered 2 days before I calculated: 31/03/2008 00:00:00 - 2days (read 48hours).This however is not the expected 29/03/2008 00:00:00 but due to the hour change: 28/03/2008 23:00:00. So searching ordered amounts for that date resulted in nothing :doh:. Well I must say it was an interesting bug, that had me scratching my head for a little while :)
I think it's definitely a bug, but not a subtle one.
GDavy wrote:
the whole DB system is written in-house.
So it's you or your co-workers who forgot about time changes, did your forgot about leap years too? Did you managed to repair this, or you gonna have similar problem in about half a year? Another thing is why your are inventing wheel again, when you have ready functions to operate on date/time.. I would call it a WTF[^] I rest my case.. ;)
Communism doesn't work because people like to own stuff. Frank Zappa
-
I think it's definitely a bug, but not a subtle one.
GDavy wrote:
the whole DB system is written in-house.
So it's you or your co-workers who forgot about time changes, did your forgot about leap years too? Did you managed to repair this, or you gonna have similar problem in about half a year? Another thing is why your are inventing wheel again, when you have ready functions to operate on date/time.. I would call it a WTF[^] I rest my case.. ;)
Communism doesn't work because people like to own stuff. Frank Zappa
s.t.a.v.o wrote:
your are inventing wheel again, when you have ready functions to operate on date/time.
I do not see where the wheel is re-invented here. The application is written in embedded Visual C++ 4.0. Simple example: I'll use:
s.t.a.v.o wrote:
ready functions to operate on date/time
Imagine you have a function that gets a CTime input and outputs as a string the day before the input date:
void PreviousDayAsString(CTime aDay, CString& dayBefore) { aDay -= CTimeSpan(1,0,0,0); //substract 1day dayBefore.Format(_T("%02d-%02d-%d"), aDay.GetDay(), aDay.GetMonth(), aDay.GetYear()); }
if the input date is 31/03/2008 00:00:00 (12am) then output string is 29-03-2008. Tell me where the wheel is reinvented and what is WTF about this seemingly simple, logic piece of code. I rest my case. ;P -
ummm getting burned by daylight savings shifts certainly seems like s subtle bug to me.
Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop. -- Matthew Faithfull
Hi We are looking for webmethods professionals for south africa . experience in BAM is absolutely necessary. please call on 04040150478 or 9849128646. regards Rahul www.binaryberries.com
-
ummm getting burned by daylight savings shifts certainly seems like s subtle bug to me.
Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop. -- Matthew Faithfull
dan neely wrote:
getting burned by daylight savings shifts certainly seems like s subtle bug to me.
I agree. This is July and I am finally getting used to it :-\
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon