3 ms·
Don't forget time comparison. Your unit test of a function comparing dates relies on server time and usually fails if run around 12pm. Whatever. Nobody uses
by ravenstine 6y ago
Don't forget time comparison.
Your unit test of a function comparing dates relies on server time and usually fails if run around 12pm. Whatever. Nobody uses this app around lunch time anyway. Just tell your teammates in the to ignore that. Wait, why is the test failing every time today?! Did we just switch to DST? Uh oh...
- papito 6y agoThis has to come with a trigger warning.
- fiddlerwoaroof 6y ago“Our JavaScript date library and the date library we’re using in Clojure disagree on the first day of the week. Elasticsearch disagrees with both too”
- emodendroket 6y agoYou can avoid this problem by always passing in either a time or a time provider and never just relying on Time.now or whatever it is your language provides.
- fiddlerwoaroof 6y agoThis. Nearly every date/time library comes with this sort of attractive nuisance that is just waiting for a chance to ruin your day.
- gavinflud 6y agoFunnily enough, I recently had to help with an issue where a company's payment screen was not loading correctly and instead displaying "Invalid session". They use a third-party vendor to handle payments and display their payment form in an iFrame on their website. There is an initial request to create a session that has to pass the desired expiration time of the session. Unfortunately, the vendor requires the time to be in Eastern Time. The poor, naive soul that originally implemented this just got the current date, added 15 minutes, and converted it to "EST". As soon as daylight savings hit a few weeks ago, the expiration time was automatically being set to 45 minutes in the past, the vendor was responding with "Invalid Session" and the company was unable to take payments from customers.
- mnutt 6y agoI recently came across a 15 year old bug in qt involving both time comparison _and_ cache invalidation: the code was trying to set timers to fire when the next cache entry was set to expire, but the timeout was in seconds while the eviction code compared milliseconds. The result was 100% cpu usage for up to a second as the timer spun without evicting the cache entry.
- neilparikh 6y agoFunny related story: For an internship, I worked on a app that would show your sleep data in a nice visualization (this was for a smartwatch). I implemented a basic version, and used it for a few weeks. It seemed to work fine for me, so I released a beta version for others in the company to dog food. Within a day, I got a bug report from a coworker that it rendered incorrectly for them. I was pretty surprised, since I had been using it for a long enough that I would have expected to encounter all the edge cases. I dug into the code, and realized that this bug only happened if you went to sleep before midnight, which I never did...