Sha256: a5205f0538a05d151992151e4b48269bf67f3438674b4b33f5113712cd9edff3

Contents?: true

Size: 700 Bytes

Versions: 13

Compression:

Stored size: 700 Bytes

Contents

module Formulario
  class Field
    class Time < DefaultTimeField

      private

      def self.base_class
        ::Time
      end

      def self.allowed_keys
        %i[ year month day hour minute second timezone ]
      end

      def self.parse_hash(hash)
        return invalid_keys_exceptional_value(hash) if has_invalid_keys?(hash)

        now = ::Time.now
        new ::Time.new(
          hash[:year]     || now.year,
          hash[:month]    || now.month,
          hash[:day]      || now.day,
          hash[:hour]     || now.hour,
          hash[:minute]   || now.min,
          hash[:second]   || now.sec,
          hash[:timezone] || now.zone,
        )
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
formulario-0.1.12 lib/formulario/fields/time.rb
formulario-0.1.11 lib/formulario/fields/time.rb
formulario-0.1.10 lib/formulario/fields/time.rb
formulario-0.1.9 lib/formulario/fields/time.rb
formulario-0.1.8 lib/formulario/fields/time.rb
formulario-0.1.6 lib/formulario/fields/time.rb
formulario-0.1.5 lib/formulario/fields/time.rb
formulario-0.1.4 lib/formulario/fields/time.rb
formulario-0.1.3 lib/formulario/fields/time.rb
formulario-0.1.2 lib/formulario/fields/time.rb
formulario-0.1.1b lib/formulario/fields/time.rb
formulario-0.1.1 lib/formulario/fields/time.rb
formulario-0.1.0 lib/formulario/fields/time.rb