method

iso8601

Importance_2
v5.2.3 - Show latest stable - 0 notes - Class: ActiveSupport::TimeZone
iso8601(str) public

Method for creating new ActiveSupport::TimeWithZone instance in time zone of self from an ISO 8601 string.

Time.zone = 'Hawaii'                     # => "Hawaii"
Time.zone.iso8601('1999-12-31T14:00:00') # => Fri, 31 Dec 1999 14:00:00 HST -10:00

If the time components are missing then they will be set to zero.

Time.zone = 'Hawaii'            # => "Hawaii"
Time.zone.iso8601('1999-12-31') # => Fri, 31 Dec 1999 00:00:00 HST -10:00

If the string is invalid then an ArgumentError will be raised unlike parse which usually returns nil when given an invalid date string.

Show source
Register or log in to add new notes.