method

parts_to_time

Importance_0
v6.1.7.7 - Show latest stable - 0 notes - Class: ActiveSupport::TimeZone
parts_to_time(parts, now) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activesupport/lib/active_support/values/time_zone.rb, line 553
      def parts_to_time(parts, now)
        raise ArgumentError, "invalid date" if parts.nil?
        return if parts.empty?

        if parts[:seconds]
          time = Time.at(parts[:seconds])
        else
          time = Time.new(
            parts.fetch(:year, now.year),
            parts.fetch(:mon, now.month),
            parts.fetch(:mday, parts[:year] || parts[:mon] ? 1 : now.day),
            parts.fetch(:hour, 0),
            parts.fetch(:min, 0),
            parts.fetch(:sec, 0) + parts.fetch(:sec_fraction, 0),
            parts.fetch(:offset, 0)
          )
        end

        if parts[:offset] || parts[:seconds]
          TimeWithZone.new(time.utc, self)
        else
          TimeWithZone.new(nil, self, time)
        end
      end
Register or log in to add new notes.