lib/timeliness/definitions.rb
# Returns format for type and other possible matching format set based on type
# and value length. Gives minor speed-up by checking string length.
#
Returns format for type and other possible matching format set based on type
and value length. Gives minor speed-up by checking string length.
Returns format for type and other possible matching format set based on type and value length . Gives minor speed - up by checking string length .
def format_sets(type, string)
        case type
        when :date
          [ date_format_set, datetime_format_set ]
        when :datetime
          if string.length < 11
            [ date_format_set, datetime_format_set ]
          else
            [ datetime_format_set, date_format_set ]
          end
        when :time
          if string.length < 11
            [ time_format_set ]
          else
            [ datetime_format_set, time_format_set ]
          end
        else
          if string.length < 11
            [ date_format_set, time_format_set, datetime_format_set ]
          else
            [ datetime_format_set, date_format_set, time_format_set ]
          end
        end
      end
def format_sets ( type , string ) case type when :date [ date_format_set , datetime_format_set ] when :datetime if string . length < 11 [ date_format_set , datetime_format_set ] else [ datetime_format_set , date_format_set ] end when :time if string . length < 11 [ time_format_set ] else [ datetime_format_set , time_format_set ] end else if string . length < 11 [ date_format_set , time_format_set , datetime_format_set ] else [ datetime_format_set , date_format_set , time_format_set ] end end end
Returns format for type and other possible matching format set based on type
and value length.
Returns format for type and other possible matching format set based on type and value length .
type
string