4 ms·
Show HN: I Fixed Apple's Broken Weather Dashboard Widget
- Wowfunhappy 7y agoHi HN! This is one of those things that became a bit of a rabbit hole. When I started out, I was just futzing around—I didn't think this widget would actually be fixable—and then once I saw it starting to come back to life, I felt the need to finish what I started. But also—I have an emotional attachment to Leopard-era macOS, in a way I never have with any other piece of software. I've spent a significant amount of effort over the past year downgrading my life to 2013-era OS X 10.9 Mavericks, and I wanted to have a fully working system at the end of it. Dashboard is a pretty important part of the OS, and this is a signature widget. A majority of the code in WeatherParser.js is original, and it comprises the bulk of what I wrote. By contrast, I don't understand how most of Weather.js works, and I tried to edit it as little as possible. Some tidbits HN readers might find interesting: • The original widget sent a zipcode or city name to the weather provider as input; DarkSky only accepts coordinates. This meant I had to both (A) add another API for reverse geolocation and (B) somehow hold onto the city name so it could be displayed later. The latter may have actually been the big • I can't figure out what the two big arrays at the beginning of weatherParser.js actually do. They seemingly map weather condition numbers from the API to the names of specific weather icons—but relying on those numbers results in the wrong icons being displayed. (I discovered the right numbers via trial and error.) • Users of very old versions of OS X (10.8 and older) ran into SSL issues connecting to DarkSky. My suggested workaround: https://forums.macrumors.com/threads/i-fixed-apples-broken-weather-dashboard-widget.2225715/post-28275324 https://forums.macrumors.com/threads/i-fixed-apples-broken-w... • Timezone issues are fun: https://forums.macrumors.com/threads/i-fixed-apples-broken-weather-dashboard-widget.2225715/post-28297774 https://forums.macrumors.com/threads/i-fixed-apples-broken-w... I was originally calculating the day of the week via Javascript's getDay(), but this doesn't work when users are viewing the weather for a location where it's still yesterday or already tomorrow. Simultaneously, I actually forgot how the original widget was supposed to work, which caused me to misinterpet user bug reports.