# Time vs Datetime vs Date

**URL:** <https://www.ruby-forum.com/t/time-vs-datetime-vs-date/132035>\
**Category:** Ruby\
**Created:** [March 15, 2008, 6:30pm UTC](https://www.ruby-forum.com/t/time-vs-datetime-vs-date/132035 "2008-03-15T18:30:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [March 15, 2008, 6:30pm UTC](https://www.ruby-forum.com/t/time-vs-datetime-vs-date/132035/1 "2008-03-15T18:30:56Z")

</div>

Hi all,

why are there three different classes representing time? I think that is  
a really bad spot in the ruby library, because Time and DateTime seem to  
be incompatible to each other. For example in rails sql columns declared  
as datetime are returned as time, so I had to convert them manually. It  
doesn’t seems to be consistent…

Daniel

---

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [March 16, 2008, 2:33am UTC](https://www.ruby-forum.com/t/time-vs-datetime-vs-date/132035/2 "2008-03-16T02:33:13Z")

</div>

On Mar 15, 9:05 pm, Stefan R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> IMO they all suck. I invite everybody with spare time and some ruby/C  
> knowledge to help me finish chronos  
> ([http://butler.rubyforge.org/svn/Version%201.0/chronos\_library/-](http://butler.rubyforge.org/svn/Version%201.0/chronos_library/-)  
> missing are DST implementation, refactoring to use modules so that one  
> can use it with Gregiorian, Julian, Chinese, Discordian or whatever  
> calendar system he/she likes, C implementation of the math stuff for  
> gregorian even though the ruby implementation beats Date by around  
> factor 10, calendar - a mutable gregorian datetime object and some other  
> things).

I would recommend finishing in Ruby first. Worry about C optimizations  
later.

2 cents,  
T.

---

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [March 16, 2008, 2:05am UTC](https://www.ruby-forum.com/t/time-vs-datetime-vs-date/132035/3 "2008-03-16T02:05:18Z")

</div>

Daniel M. wrote:

> Hi all,
> 
> why are there three different classes representing time? I think that is  
> a really bad spot in the ruby library, because Time and DateTime seem to  
> be incompatible to each other. For example in rails sql columns declared  
> as datetime are returned as time, so I had to convert them manually. It  
> doesn’t seems to be consistent…
> 
> Daniel

IMO they all suck. I invite everybody with spare time and some ruby/C  
knowledge to help me finish chronos  
([http://butler.rubyforge.org/svn/Version%201.0/chronos\_library/](http://butler.rubyforge.org/svn/Version%201.0/chronos_library/) -  
missing are DST implementation, refactoring to use modules so that one  
can use it with Gregiorian, Julian, Chinese, Discordian or whatever  
calendar system he/she likes, C implementation of the math stuff for  
gregorian even though the ruby implementation beats Date by around  
factor 10, calendar - a mutable gregorian datetime object and some other  
things).  
Anyway, to answer your question: Time is a wrapper around Unix-Epoch.  
Date (and DateTime) use rational and a “day zero” for storage. So Time  
is faster but the upper and lower bounds are tied to epoch time (which  
for 32bit epoch times is something around 1970-2040 - not even enough to  
represent the birthsday of my parents) while Date (and DateTime) have an  
almost infinite range but are _terribly_ slow. And both classes’  
interfaces are less than stellar IMO.

Regards  
Stefan

---

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [March 16, 2008, 2:46am UTC](https://www.ruby-forum.com/t/time-vs-datetime-vs-date/132035/4 "2008-03-16T02:46:29Z")

</div>

Trans wrote:

> On Mar 15, 9:05 pm, Stefan R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > IMO they all suck. I invite everybody with spare time and some ruby/C  
> > knowledge to help me finish chronos  
> > ([http://butler.rubyforge.org/svn/Version%201.0/chronos\_library/-](http://butler.rubyforge.org/svn/Version%201.0/chronos_library/-)  
> > missing are DST implementation, refactoring to use modules so that one  
> > can use it with Gregiorian, Julian, Chinese, Discordian or whatever  
> > calendar system he/she likes, C implementation of the math stuff for  
> > gregorian even though the ruby implementation beats Date by around  
> > factor 10, calendar - a mutable gregorian datetime object and some other  
> > things).
> 
> I would recommend finishing in Ruby first. Worry about C optimizations  
> later.
> 
> 2 cents,  
> T.

Sure, why do you think I first wrote it completly in ruby anyway? 🙂  
(prototyping)  
I intend to have all C functionality in ruby too. Will enable it to run  
on non-MRI easily.  
C will be the very last step.

Regards  
Stefan
