class TZInfo::DateTimeWithOffset

UTC (‘offset`). The associated {TimezoneOffset} will aways be cleared.
results of arithmetic operations will always maintain the same offset from
zone-aware. Regardless of whether transitions in the time zone are crossed,
Arithmetic performed on {DateTimeWithOffset} instances is not time
to `DateTime`.
{TimezoneOffset} has been cleared, {DateTimeWithOffset} behaves identically
{TimezoneOffset} would not necessarily be valid for the result). Once the
operations will clear the associated {TimezoneOffset} (if the
methods to return results appropriate for the {TimezoneOffset}. Certain
holds a reference to the related {TimezoneOffset} and overrides various
A subclass of `DateTime` used to represent local times. {DateTimeWithOffset}

def clear_timezone_offset

Returns:
  • (DateTimeWithOffset) - `self`.
def clear_timezone_offset
  @timezone_offset = nil
  self
end

def downto(min)

{TimezoneOffset} of the returned or yielded instances.
An overridden version of `DateTime#downto` that clears the associated
def downto(min)
  if block_given?
    super {|dt| yield dt.clear_timezone_offset }
  else
    enum = super
    enum.each {|dt| dt.clear_timezone_offset }
    enum
  end
end

def england

Returns:
  • (DateTime) -
def england
  # super doesn't call #new_start on MRI, so each method has to be
  # individually overridden.
  if_timezone_offset(super) {|o,dt| dt.set_timezone_offset(o) }
end

def gregorian

Returns:
  • (DateTime) -
def gregorian
  # super doesn't call #new_start on MRI, so each method has to be
  # individually overridden.
  if_timezone_offset(super) {|o,dt| dt.set_timezone_offset(o) }
end

def italy

Returns:
  • (DateTime) -
def italy
  # super doesn't call #new_start on MRI, so each method has to be
  # individually overridden.
  if_timezone_offset(super) {|o,dt| dt.set_timezone_offset(o) }
end

def julian

Returns:
  • (DateTime) -
def julian
  # super doesn't call #new_start on MRI, so each method has to be
  # individually overridden.
  if_timezone_offset(super) {|o,dt| dt.set_timezone_offset(o) }
end

def new_start(start = Date::ITALY)

Returns:
  • (DateTime) -
def new_start(start = Date::ITALY)
  if_timezone_offset(super) {|o,dt| dt.set_timezone_offset(o) }
end

def set_timezone_offset(timezone_offset)

Raises:
  • (ArgumentError) - if `timezone_offset.observed_utc_offset` does not
  • (ArgumentError) - if `timezone_offset` is `nil`.

Returns:
  • (DateTimeWithOffset) - `self`.

Parameters:
  • timezone_offset (TimezoneOffset) -- a {TimezoneOffset} valid at the
def set_timezone_offset(timezone_offset)
  raise ArgumentError, 'timezone_offset must be specified' unless timezone_offset
  raise ArgumentError, 'timezone_offset.observed_utc_offset does not match self.utc_offset' if offset * 86400 != timezone_offset.observed_utc_offset
  @timezone_offset = timezone_offset
  self
end

def step(limit, step = 1)

{TimezoneOffset} of the returned or yielded instances.
An overridden version of `DateTime#step` that clears the associated
def step(limit, step = 1)
  if block_given?
    super {|dt| yield dt.clear_timezone_offset }
  else
    enum = super
    enum.each {|dt| dt.clear_timezone_offset }
    enum
  end
end

def to_time

Returns:
  • (Time) - if there is an associated {TimezoneOffset}, a
def to_time
  if_timezone_offset(super) do |o,t|
    # Ruby 2.4.0 changed the behaviour of to_time so that it preserves the
    # offset instead of converting to the system local timezone.
    #
    # When self has an associated TimezonePeriod, this implementation will
    # preserve the offset on all versions of Ruby.
    TimeWithOffset.at(t.to_i, t.subsec * 1_000_000).set_timezone_offset(o)
  end
end

def upto(max)

{TimezoneOffset} of the returned or yielded instances.
An overridden version of `DateTime#upto` that clears the associated
def upto(max)
  if block_given?
    super {|dt| yield dt.clear_timezone_offset }
  else
    enum = super
    enum.each {|dt| dt.clear_timezone_offset }
    enum
  end
end