Method: Vcard.decode_date_time

Defined in:
lib/vcard.rb

.decode_date_time(v) ⇒ Object

Convert a RFC 2425 date-time into an array of [year,mon,day,hour,min,sec,secfrac,timezone]



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/vcard.rb', line 111

def self.decode_date_time(v) # :nodoc:
  raise ::Vcard::InvalidEncodingError, "date-time '#{v}' not valid" unless match = Bnf::DATE_TIME.match(v)
  year, month, day, hour, min, sec, secfrac, tz = match.to_a[1..8]

  [
    # date
    year.to_i, month.to_i, day.to_i,
    # time
    hour.to_i, min.to_i, sec.to_i, secfrac ? secfrac.to_f : 0, tz
  ]
end