
When should you use DateTime and when should you use Time? - aps-sids
https://gist.github.com/pixeltrix/e2298822dd89d854444b
======
anton_gogolev
Two obligatory links on what a strange thing "time" is:

[1]: [http://infiniteundo.com/post/25326999628/falsehoods-
programm...](http://infiniteundo.com/post/25326999628/falsehoods-programmers-
believe-about-time)

[2]: [http://infiniteundo.com/post/25509354022/more-falsehoods-
pro...](http://infiniteundo.com/post/25509354022/more-falsehoods-programmers-
believe-about-time)

------
colinramsay
This is superbly well explained with a great example but it doesn't quite
explain why I wouldn't just use DateTime for everything? Or did I miss
something?

~~~
trebor
TL;DR, use Time _except_ when you need to deal with historical dates in their
context.

This was actually explained in the last paragraph of that post. Emphasis mine.

> So when should use you use DateTime in Ruby and when should you use Time?
> Almost certainly you'll want to _use Time since your app is probably dealing
> with current dates_ and times. However, _if you need to deal with dates and
> times in a historical context you 'll want to use DateTime_[...]

~~~
Zikes
That's not an explanation, it's a recommendation. The author does not state
_why_ Time should be preferred over DateTime.

~~~
fleitz
They do, which is because Time supports timezones, etc.

~~~
Semiapies
The gist was updated.

------
thwarted
_We can see the actual date of Shakespeare 's death by using..._

The use of "actual" seems dubious in this context. The whole point of this
gist is that time interpretation is relative. I like how the author makes the
distinction with "solar years" later on.

