Philosophy

Philosophy

Tempo is intended to be “the date time library I wish Dart had shipped with.” The standard library’s date and time types lack important features and are too easy to use incorrectly.

Dates and times mean different things in different contexts, and the answers to the questions we ask about them depend on those contexts. Types that assume one context may fail in another.

If, for example, you use a DateTime to store the date and time of a personal reminder, and you add 24 hours to get the “same time the next day,” your code will usually work as expected. But every once in a while, depending on where your code is running, it will give the wrong answer. Because of daylight savings time—summer time—whatever it’s called where you live, it broke your code.

There are two solutions: First, different types for different jobs. In the example above, using a type that doesn’t have a time zone would have prevented the bug. The application didn’t need one, and a type that included it actually made things more difficult.

The second solution is more powerful features. Maybe you really did need the time zone. Adding one day without messing with the time is a common requirement. It should be possible without investing hours of work and testing.

Tempo implements both.

Sometimes you need a date and time type that’s globally meaningful. Sometimes you need one that’s only locally meaningful. The right type in the right place makes for clearer code and fewer bugs. And more powerful features let you focus on your own project, without getting sidetracked.

(Unless you really want to, of course. Tempo wouldn’t exist if I hadn’t gotten thoroughly sidetracked. I’m not complaining, though. This is fun.)