Class: When::BasicTypes::DateTime

Inherits:
String
  • Object
show all
Defined in:
lib/when_exe/basictypes.rb

Overview

ISO 8601 Date and Time Representation

see xml schema

Direct Known Subclasses

Date, Time

Class Method Summary collapse

Methods inherited from String

#^, #calendar, #calendar_era, #calendar_note, #encode, #era, #ideographic_unification, #m17n, #ord, #resource, #to_m17n, #to_month_name, #to_pair, #to_r, #to_residue, #translate, #when?

Class Method Details

._to_array(date_time, options = {}) ⇒ Array

When.exe Standard Representation 形式の表現を分解してArray化する

Options Hash (options):

  • :era_name (String, Array<String, Integer>)

    デフォルトの年号(Integerは0年に対応する通年)

  • :abbr (Array<Numeric>)

    上位省略形式で使用する上位部分

  • :extra_year_digits (Integer)

    ISO8601拡大表記のための年の構成要素拡大桁数(省略時 1桁)

Raises:

  • (TypeError)

47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/when_exe/basictypes.rb', line 47

def _to_array(date_time, options={})
  raise TypeError, "Argument is not ISO 8601 String" unless date_time.kind_of?(String)
  if options[:abbr].kind_of?(When::TimeValue)
    options[:abbr] = ((options[:frame]||When.Calendar('Gregorian')) ^ options[:abbr]).cal_date
  end
  date_time = date_time.gsub(/_([\d])/, '\1')
  begin
    return _to_array_basic(date_time, options)
  rescue ArgumentError
    return _to_array_extended(date_time, options)
  end
end