class Time

def rfc3339(str)

Time.rfc3339('1999-12-31') # => ArgumentError: invalid date

If the time or offset components are missing then an +ArgumentError+ will be raised.

Time.rfc3339('1999-12-31T14:00:00-10:00') # => 2000-01-01 00:00:00 -1000

Creates a +Time+ instance from an RFC 3339 string.
def rfc3339(str)
  parts = Date._rfc3339(str)
  raise ArgumentError, "invalid date" if parts.empty?
  Time.new(
    parts.fetch(:year),
    parts.fetch(:mon),
    parts.fetch(:mday),
    parts.fetch(:hour),
    parts.fetch(:min),
    parts.fetch(:sec) + parts.fetch(:sec_fraction, 0),
    parts.fetch(:offset)
  )
end