Issue #7114 has been updated by wardrop (Tom Wardrop).


Personally, I find Ruby's whole Time API to be lack-luster and frustrating. It's probably the thing I like least about Ruby. I'd be in favor of a total redesign of Ruby's Time classes. A certain number of improvements could be made without creating backwards compatibility problems (look at ActiveRecord), but a total new set of classes would be preferred. You can have a base class of Time (maybe in a new namespace) with a whole load of subclasses for representing different types of time, e.g. Date, DateTime, Duration, Range, etc, and there should be logical operator support between all of this, e.g. DateTime - Duration should behave as expected, and a class like Range could have all kinds of useful methods like Date.today.in(Range.new '2012-01-01', '2012-12-31'). Range would also allow for methods like Range.from_year(2012) which would be the same as Range.new('2012-01-01', '2012-12-31') . Of course, ranges and duration are similar, so you'd have methods to convert between the
  two, e.g. Range.to_duration and Duration.to_range('2012-10-01') which would create a date range beginning at the given date/time which would extend for the duration of the Duration object (self).

There's some real potential there obviously. Times are painful enough in programming. You have to parse ambiguous date formats like 12/12/2012, deal with timezones and store and retrieve times from other systems which have there own quirks. Having a solid Time library would make dealing with this common problem just that little less painful.
----------------------------------------
Feature #7114: New classes: `HumanTime::LocalTime`, `HumanTime::Duration`
https://bugs.ruby-lang.org/issues/7114#change-31033

Author: alexeymuranov (Alexey Muranov)
Status: Feedback
Priority: Normal
Assignee: 
Category: 
Target version: 


=begin
As suggested by  *drbrain* in #7113 , here is a separate request for classes to hold the time of day and duration of time.

Ruby currently does not have a class to represent a standard database "time" column. Using (({Time})) for this causes some difficulties for example to users of *Ruby on Rails*: http://www.rebeccablyth.co.uk/2008/01/03/time-columns-and-rails/
=end



-- 
http://bugs.ruby-lang.org/