module Nexpose::ISO8601
Function module for converting to ISO 8601 and UTC dates expected by 2.0 API.
Public Instance Methods
to_string(time = Time.now)
click to toggle source
Convert a time object into a UTC ISO 8601 basic date-time format.
@param [Time|Date|DateTime] time Time to convert. @return [String] ISO 8601 basic representation.
# File lib/nexpose/util.rb, line 105 def to_string(time = Time.now) time.to_time.utc.strftime('%Y%m%dT%H%M%S.%LZ') end
to_time(time_string)
click to toggle source
Convert a string representation into a Time object.
@param [String] time_string String representation in basic format.
For example: '20141210T165822.412Z'
@return [Time] Time, if it can be converted.
# File lib/nexpose/util.rb, line 96 def to_time(time_string) Time.strptime(time_string.to_s, '%Y%m%dT%H%M%S.%L%Z') end