TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Brain Hayes on the Zune Bug

16 pointsby muonover 16 years ago

4 comments

StrawberryFrogover 16 years ago
To those that claim "dealing with dates is not easy", a really simple unit test would have caught that bug - like feeding the function integers from 1 to 1000 and testing that it did not crash for any of them. Bonus points for testing that it returned something sensible each time.<p>Sadly, this code probably wasn't unit tested at all.
axodover 16 years ago
The lookup table solution in the comments seems sane enough, Always nicer to do lookups than loops. You could improve on it by pretty much runlength encoding the table. Instead of storing 0,0,0,0 just store the number of 0s, although then you might need to iterate instead of simple lookup which would negate the point of using a lookup.<p>Also seems like most RTC chips I've worked with store the year,date,month as BCD or similar, and deal with the rollovers as they occur, on the chip. Only Storing days since 1980 seems like a lot more work in software.<p>I do think it's quite right to put the blame squarely at MS for this though, a simple code review, or a quick test plan would have picked it up easily.
评论 #425051 未加载
评论 #425720 未加载
mattmaroonover 16 years ago
Why 1980? The Zune came out in what, 2006? I realize it's more or less arbitrary, but why not 2000.
评论 #425513 未加载
评论 #425268 未加载
mattmichielsenover 16 years ago
It all comes down to the fact that dealing with the Gregorian calendar (and time in general) is not easy. And that's because our system is based on the position of the planet in relation to the sun. Let's get on with implementing Metric time already.
评论 #425267 未加载