rust-datetime / datetime

Dates and times library for Rust.
MIT License
15 stars 9 forks source link

replaced `trait TimeZone` with `enum TimeZone` #8

Closed hoodie closed 9 years ago

hoodie commented 9 years ago

Hi, there. When I though of an enum for TimeZone I rather imagined replacing the trait TimeZone all together. I think this would make for a much nicer API, since LocalDateTime and ZonedDateTime could now be initiated almost the same way. I haven't done any benchmarking here yet, but all the tests this work. What do you think about this kind of implementation?

ogham commented 9 years ago

I'll allow it! :+1:

When I initially wrote the API, I wanted the different types of time zone to be separate types so there was no chance I'd confuse them and write code for one that was meant for another, such as converting a variable time zone type as though it were UTC. The downside of this (that I hadn't considered) was that it made it impossible for for a function to return a time with any type of time zone. The enum I added helps with this a bit, but even with that you have to deal with converting time zones between one type and another, and who wants to deal with that when you can only have one type instead?

So yeah, I'll merge this - especially if it makes your parsing code easier to write.

hoodie commented 9 years ago

\o/ yohoo!