Code that breaks 2 or 3 times every month
ngzhian.github.io
Code that breaks 2 or 3 times every month
1–10 of 20 posts
Re: Code that breaks 2 or 3 times every month
#2Re: Code that breaks 2 or 3 times every month
#3umm... it's because the date 31st isn't in those months... Simply, they're switching to February 2006, because you did not specify a day.
I really don't see the use case for that anywhere.
Re: Code that breaks 2 or 3 times every month
#4umm... it's because the date 31st isn't in those months... Simply, they're switching to February 2006, because you did not specify a day.
Sure enough. But is it a sane thing to do for a "convert readable date to date object" function to silently amend the current day-of-month to a otherwise underdpecified date? I really don't see the use case for that anywhere.
Re: Code that breaks 2 or 3 times every month
#5The test created models for a few days and tested for a sum of the current week. The dates where all relative (today, yesterday, etc.), so when the test run on a Monday some records where for the last week and that's why the sum wasn't the same.
But I guess your problem is harder to debug.
Re: Code that breaks 2 or 3 times every month
#6umm... it's because the date 31st isn't in those months... Simply, they're switching to February 2006, because you did not specify a day.
Sure enough. But is it a sane thing to do for a "convert readable date to date object" function to silently amend the current day-of-month to a otherwise underdpecified date? I really don't see the use case for that anywhere.
Probably hard to fix backwards compatible though...
Re: Code that breaks 2 or 3 times every month
#7Re: Code that breaks 2 or 3 times every month
#8Re: Code that breaks 2 or 3 times every month
#9I started making some small seemingly insignificant changes to my code and suddenly my app generated all the reports quickly. All was well until the next month when I had to generate the same reports and my app failed on the same query. I solved it by reverting the small insignificant change I made the previous month. WTF.
I looked into it and there's a wealth of information on the topic[0]. Apparently, how my code passed the query to the database differed to how I tested my query directly on the database which cause the database to compile the query differently and use different execution plans.
My most recent fix was to add another index which the database suggested. Let's hope it works next month.
Re: Code that breaks 2 or 3 times every month
#10Earlier quoted context omitted.
Sure enough. But is it a sane thing to do for a "convert readable date to date object" function to silently amend the current day-of-month to a otherwise underdpecified date? I really don't see the use case for that anywhere.
I would expect to use the first day of a month as a default, just like when time is not specified it should use 00:00 as default. Taking the current time/day as a default sounds off. Probably hard to fix backwards compatible though...
Javascript:
new Date("Feb 2006")
> Wed Feb 01 2006 00:00:00 GMT-0800 (Pacific Standard Time)
Ruby: require 'time'
Time.parse "Feb 2006"
=> 2006-02-01 00:00:00 -0700