Class: When::V::Timezone

Inherits:
Root show all
Extended by:
Parts::Resource::Pool
Defined in:
lib/when_exe/icalendar.rb

Overview

Timezone を定義する

BEGIN:VTIMEZONE...END:VTIMEZONE のブロックに対応

Constant Summary collapse

Properties =
[['tzid'], [],
['last_modified', 'tzurl', 'x_lic_location'], [], []]
Classes =
[Standard, Daylight]

Constants inherited from Root

Root::AwareProperties, Root::DefaultOptional, Root::DefaultUnique

Constants included from Parts::Resource

Parts::Resource::LabelProperty

Instance Attribute Summary collapse

Attributes inherited from Root

#calscale, #property

Attributes included from Parts::Resource

#_pool, #child, #keys, #locale, #namespace

Instance Method Summary collapse

Methods included from Parts::Resource::Pool

[], []=, _pool, _setup_, pool_keys

Methods included from Parts::Resource::Synchronize

#synchronize

Methods inherited from Root

#_enumerator, #include?

Methods inherited from BasicTypes::Object

#tap

Methods included from Parts::Resource

#[], #^, _extract_prefix, _instance, _parse, _path_with_prefix, _setup_, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #next, #parent, #prev, #registered?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class When::Parts::Resource

Instance Attribute Details

#daylightWhen::TM::Clock (readonly)

夏時間帯の時計

Returns:



847
848
849
# File 'lib/when_exe/icalendar.rb', line 847

def daylight
  @daylight
end

#differenceWhen::TM:IntervalLength (readonly)

夏時間帯と標準時間帯の時間差

Returns:

  • (When::TM:IntervalLength)


851
852
853
# File 'lib/when_exe/icalendar.rb', line 851

def difference
  @difference
end

#standardWhen::TM::Clock (readonly)

標準時間帯の時計

Returns:



843
844
845
# File 'lib/when_exe/icalendar.rb', line 843

def standard
  @standard
end

Instance Method Details

#_daylight(zdate = nil) ⇒ Object

Raises:

  • (ArgumentError)


876
877
878
879
880
881
882
883
884
885
886
887
# File 'lib/when_exe/icalendar.rb', line 876

def _daylight(zdate=nil)
  raise ArgumentError, "Needless daylight saving time evaluation" unless _need_validate
  zdate = yield(@standard.dup.tap{|clock| clock.tz_prop = nil}) if block_given?
  ndate = _neighbor_event_date(zdate)
  nprop = ndate.clock.tz_prop
  if block_given? && !@standard.equal?(nprop.tzoffsetfrom)
    zdate = yield(nprop.tzoffsetfrom.dup.tap{|clock| clock.tz_prop = nil})
  end
  deltad = zdate.universal_time - ndate.universal_time
  return nprop.tzoffsetto   if (deltad >= 0)
  return nprop.tzoffsetfrom
end

#_need_validateObject



890
891
892
# File 'lib/when_exe/icalendar.rb', line 890

def _need_validate
  (@difference != 0)
end

#current_period(current_date = Time.now) ⇒ Range

同一の時間帯を用いた期間

Parameters:

Returns:

  • (Range)
    期間が過去または未来に対して無限に続く場合は、GeometricComplex
    期間が有界の場合は、start…end という形式の Range


867
868
869
870
871
872
873
# File 'lib/when_exe/icalendar.rb', line 867

def current_period(current_date=Time.now)
  current_date = When.when?(current_date) unless current_date.kind_of?(When::TM::TemporalPosition)
  period = _tz_period(current_date)
  range  = period[1]
  return range if range.kind_of?(Range)
  GeometricComplex.new([period], !range)
end

#labelString

ユニーク識別名 - TZID Property をユニーク識別名とする

Returns:



855
856
857
# File 'lib/when_exe/icalendar.rb', line 855

def label
  @property['tzid'].object
end