class ActiveSupport::Duration::ISO8601Serializer
def serialize
def serialize parts = normalize return "PT0S" if parts.empty? output = +"P" output << "#{parts[:years]}Y" if parts.key?(:years) output << "#{parts[:months]}M" if parts.key?(:months) output << "#{parts[:days]}D" if parts.key?(:days) output << "#{parts[:weeks]}W" if parts.key?(:weeks) time = +"" time << "#{parts[:hours]}H" if parts.key?(:hours) time << "#{parts[:minutes]}M" if parts.key?(:minutes) if parts.key?(:seconds) time << "#{format_seconds(parts[:seconds])}S" end output << "T#{time}" unless time.empty? output end