This summer we released a new version of the weather site Väderkanalen.se
(“The Weather Channel” in Swedish), this time built using the Ruby on Rails
framework. Although we have a few tests in the test suite for the site it is far from complete. Three of the things that we have fixed since the release are results of phenomenons that shouldn’t come as a surprise. Three things that are not as certain as death and taxes but not far from it:
- There are months with 31 days.
- We actually have daylight saving time.
- It’s cold in the winter.
One: The first phenomenon was discovered in the end of August when suddenly the forecasts for September 1st shown on the site was dated as October 1st. It took a while before we realized what happened. The code for setting the date looked something like this:
var forecastDay = new Date(2010,7,31);
Tue Aug 31 2010 00:00:00 GMT+0200 (CEST)
Fri Oct 01 2010 00:00:00 GMT+0200 (CEST)
Since August have 31 days but September only 30 the 31st day of September really is October 1st. So when we set the day after setting the month we are suddenly in October. The easy fix? To set the day of month before setting the month. The correct fix? To set year, month, and date in the same method call.
Three: When the Flash rendering of the ten-day forecast suddenly went blank for some places up north last week we had a number of theories on the cause. Once again the weather service was a prime suspect but the data was in order so we began to think that it was something different with the data that the Flash code couldn’t handle. And sure enough, it turns out that the code rendering the curve of temperatures didn’t work when all temperatures in the forthcoming ten days were in the sub-zeros (Celsius degrees that is).