Module IceCube::TimeUtil
In: lib/ice_cube/time_util.rb

Methods

Classes and Modules

Class IceCube::TimeUtil::TimeWrapper

Constants

DAYS = { :sunday => 0, :monday => 1, :tuesday => 2, :wednesday => 3, :thursday => 4, :friday => 5, :saturday => 6
ICAL_DAYS = { 'SU' => :sunday, 'MO' => :monday, 'TU' => :tuesday, 'WE' => :wednesday, 'TH' => :thursday, 'FR' => :friday, 'SA' => :saturday
MONTHS = { :january => 1, :february => 2, :march => 3, :april => 4, :may => 5, :june => 6, :july => 7, :august => 8, :september => 9, :october => 10, :november => 11, :december => 12
CLOCK_VALUES = [:year, :month, :day, :hour, :min, :sec]

Public Class methods

Get a day of the month in the month of a given time without overflowing into the next month. Accepts days from positive (start of month forward) or negative (from end of month)

Get the days in the month for +time

The number of days in n months

Number of days to n years

Get the days in the following month for +time

Number of days in a year

Count the number of days to the same day of the next month without overflowing shorter months

Deserialize a time serialized with serialize_time or in ISO8601 string format

Ensure that this is either nil, or a date

Ensure that this is either nil, or a time

Get a more precise equality for time objects Ruby provides a Time#hash method, but it fails to account for UTC offset (so the current date may be different) or DST rules (so the hour may be wrong for different schedule occurrences)

Convert weekday from base sunday to the schedule‘s week start.

Provides a Time.now without the usec, in the reference zone or utc offset

Check the deserialized time offset string against actual local time offset to try and preserve the original offset for plain Ruby Time. If the offset is the same as local we can assume the same original zone and keep it. If it was serialized with a different offset than local TZ it will lose the zone and not support DST.

Serialize a time appropriate for storing

Handle discrepancies between various time types

  • Time has subsec
  • DateTime does not
  • ActiveSupport::TimeWithZone can wrap either type, depending on version or if `parse` or `now`/`local` was used to build it.

Convert a symbol to a numeric month

Convert a symbol to a wday number

Convert wday number to day symbol

Return the count of the number of times wday appears in the month, and which of those time falls on

[Validate]