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化する

Parameters:

  • date_time (String)

    日時を表現する When.exe Standard Representation 形式の文字列

  • options (Hash) (defaults to: {})

Options Hash (options):

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

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

  • :abbr (Array<Numeric>)

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

  • :extra_year_digits (Integer)

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

Returns:

  • (Array)

    format, date, time, clock, era

    format (Symbol, nil)

    nil      通常形式
    :century 世紀指定形式   ('CC', '+CCCC', '-CCCC')
    :day     年間通算日形式 ('YYDDD'など)
    :week    暦週形式       ('YYWNN'など)
    

    date (Array<Numeric>) 日付部分

    time (Array<Numeric>) 時刻部分

    clock (String) 時間帯

    era (String, Array<String, Integer>) 年号(Integerは0年に対応する通年)

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