Class: Time

Inherits:
Object show all
Defined in:
lib/microformat/time.rb

Constant Summary collapse

ISO8601_REGEX =
/^\d{4}-?\d{2}-?\d{2}(T\d{2}(:?\d{2}(:?\d{2}(\.?\d{2})?)?)?(Z|[+-]\d{2}(:?\d{2})?)?)?$/

Class Method Summary collapse

Class Method Details

.iso8601(a_string) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
# File 'lib/microformat/time.rb', line 6

def self.iso8601(a_string)
  raise ArgumentError unless a_string =~ ISO8601_REGEX

  Time.xmlschema(a_string) rescue Time.parse(a_string)
end