Datetime

Hello

Does Datetime has any advantage over Time?
Time has also the date included.
Useful could be an (only) Time (for building a 24h-only clock)

Which is the (internal) most compressed format (date till 1970 is sufficent for most cases)?

thanks
Opti

Did you read the docs or search the archive / internet?

I do not have the time to look it up for you, but as far as I
remember the use case for DateTime is explained in detail
in the docs. There are also blog posts about this, one should
even be referenced in the docs.

Short version: use Time for normal use cases.

Regards,
Marcus

···

Am 31.01.2017 um 00:48 schrieb Die Optimisten:

Does Datetime has any advantage over Time?
Time has also the date included.
Useful could be an (only) Time (for building a 24h-only clock)

--
GitHub: stomar (Marcus Stollsteimer) · GitHub
PGP: 0x6B3A101A

Hi
Yes, I read it -- therefore I wrote this mail.
Opti

···

On 2017-01-31 06:25, sto.mar@web.de wrote:

Am 31.01.2017 um 00:48 schrieb Die Optimisten:

Does Datetime has any advantage over Time?
Time has also the date included.
Useful could be an (only) Time (for building a 24h-only clock)

Did you read the docs or search the archive / internet?

I do not have the time to look it up for you, but as far as I
remember the use case for DateTime is explained in detail
in the docs. There are also blog posts about this, one should
even be referenced in the docs.

Short version: use Time for normal use cases.

Regards,
Marcus

???

Then, since you already read the docs, instead of posting
a very general question you please could be so kind and
ask specifically about the aspects of the very detailed
explanation in the docs that you did not understand.

Regards,
Marcus

···

Am 31.01.2017 um 11:29 schrieb Die Optimisten:

On 2017-01-31 06:25, sto.mar@web.de wrote:

Am 31.01.2017 um 00:48 schrieb Die Optimisten:

Does Datetime has any advantage over Time?
Time has also the date included.
Useful could be an (only) Time (for building a 24h-only clock)

Did you read the docs or search the archive / internet?

I do not have the time to look it up for you, but as far as I
remember the use case for DateTime is explained in detail
in the docs. There are also blog posts about this, one should
even be referenced in the docs.

Short version: use Time for normal use cases.

Regards,
Marcus

Hi
Yes, I read it -- therefore I wrote this mail.

--
GitHub: https://github.com/stomar/
PGP: 0x6B3A101A

I know quite a bit about Date, DateTime, Time, albeit more from the Ruby
and C code than from the documentation, and I don't think this is an
unreasonable general question: there are quite a lot of methods in all
three classes, so I don't think I'd expect someone to compare all the
methods before asking a question like this.

I think it might be helpful if at the beginning of
http://ruby-doc.org/stdlib-2.3.1/libdoc/date/rdoc/Date.html
http://ruby-doc.org/stdlib-2.3.1/libdoc/date/rdoc/DateTime.html
it stated that Time always uses the Gregorian Calendar but Date and
DateTime allow you to use the Julian Calendar or a Julian Calendar which at
a date of your choice switches to the Gregorian Calendar.

So - subject to the caveat I end this post with - use Time if you only need
the Gregorian Calendar, and use DateTime if you need the Julian Calendar or
a calendar which starts as Julian and later switched to Gregorian.

That is what is being said here:
http://ruby-doc.org/stdlib-2.3.1/libdoc/date/rdoc/DateTime.html
A subclass of Date
<http://ruby-doc.org/stdlib-2.3.1/libdoc/date/rdoc/Date.html> that easily
handles date, hour, minute, second and offset.
...
So when should 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 to avoid making
the same mistakes as UNESCO. If you also have to deal with timezones then
best of luck - just bear in mind that you’ll probably be dealing with local
solar times <http://en.wikipedia.org/wiki/Solar_time>, since it wasn’t
until the 19th century that the introduction of the railways necessitated
the need for Standard Time
<http://en.wikipedia.org/wiki/Standard_time#Great_Britain> and eventually
timezones.
...

So if for some reason you need a mixed Julian-Gregorian calendar which will
be used for both historical dates and times and for current dates and times
with timezones then neither Time nor DateTime will work.

Caveat: I think the answer isn't quite as simple as that DateTime
documentation implies, because there are some useful Date and DateTime
construction and singleton methods which aren't standard in Time. For
example: commercial, ordinal, leap?