Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8047723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:11:21+00:00 2026-06-05T06:11:21+00:00

The DateTime class seems redundant, and after reading this bit in the documentation for

  • 0

The DateTime class seems redundant, and after reading this bit in the documentation for the Rails extension of the class, it also seems potentially dangerous:

DateTimes aren’t aware of DST rules, so use a consistent non-DST offset when creating a DateTime with an offset in the local zone

There’s also this, in the Rails documentation for DateTime#to_time:

Attempts to convert self to a Ruby Time object; returns self if out of range of Ruby Time class. If self has an offset other than 0, self will just be returned unaltered, since there’s no clean way to map it to a Time.

I assume that last part is due to DateTime not recognizing DST.

It seems to me we have this:

  • The Date class represents a simple date without a time.
  • The Time class represents a specific point in time, which implicitly includes the date.
  • The DateTime class is the same as the Time class, but doesn’t understand DST and sometimes can’t convert to a regular Time class.

So should DateTime just be banished from the code base or does it serve a useful purpose which I am missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:11:23+00:00Added an answer on June 5, 2026 at 6:11 am

    DateTime had an advantage over Time on 32 bit machines in Rubies < 1.9.2 – Time was a victim of the Y2K38 problem and limited to a 32 bit range. This problem is solved either on 64 bit machines and/or in recent Ruby versions. You still may need to use DateTime if for example 1.8 compatibility is a must or you rely on using methods from its API which often deviates from that of Time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code a bit like this public class MyObject { private bool IsValidDay(ref
This seems to have most started since I upgrade my DBIx::Class and I can't
The DateTime class sure has some handy methods and seems overall superior to the
I have written this utility class to save and retrieve HttpCookies. It seems not
I have a model that looks like this: class Item(models.Model): ... publish_date = models.DateTimeField(default=datetime.datetime.now)
Here is an example class: from datetime import datetime class Article: published = datetime.now()
Continuing on my attempt to create a DateTime class , I am trying to
I have the following model: from django.db import models import datetime class Club(models.Model): establishment
I have a model with a datetime field: class MyModel(models.Model): created = models.DateTimeField(auto_now =
I have a model Coupon with an attribute expired_at , of class DateTime and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.