Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/date_time_precision/format/hash.rb

Constant Summary collapse

DATE_FORMATS =
{
  :short => [:y, :m, :d, :h, :min, :s, :sec_frac],
  :long => [:year, :month, :day, :hour, :minute, :second, :second_fraction],
  :ruby => [:year, :mon, :day, :hour, :min, :sec, :sec_frac]
}

Instance Method Summary collapse

Instance Method Details

#to_dateObject



19
20
21
# File 'lib/date_time_precision/format/hash.rb', line 19

def to_date
  Date.new(*date_time_args.take(Date::MAX_PRECISION))
end

#to_datetimeObject



15
16
17
# File 'lib/date_time_precision/format/hash.rb', line 15

def to_datetime
  DateTime.new(*date_time_args.take(DateTime::MAX_PRECISION))
end

#to_timeObject



11
12
13
# File 'lib/date_time_precision/format/hash.rb', line 11

def to_time
  Time.mktime(*date_time_args)
end