Sha256: b02b5a448f435d97038ed598329b8dc41329fc6ab25827621c7f6f925e7d31cf

Contents?: true

Size: 494 Bytes

Versions: 19

Compression:

Stored size: 494 Bytes

Contents

module Rubicure
  module Concerns
    # utility methods
    module Util
      # @param arg [Date,Time,String]
      #
      # @return [Date] arg is String, Date or Time
      # @return [nil] arg is other
      def to_date(arg)
        case arg
        when Date
          arg
        when Time
          arg.to_date
        when String
          begin
            Date.parse(arg)
          rescue
            nil
          end
        else
          nil
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rubicure-2.1.5 lib/rubicure/concerns/util.rb
rubicure-2.1.4 lib/rubicure/concerns/util.rb
rubicure-2.1.3 lib/rubicure/concerns/util.rb
rubicure-2.1.2 lib/rubicure/concerns/util.rb
rubicure-2.1.1 lib/rubicure/concerns/util.rb
rubicure-2.1.0 lib/rubicure/concerns/util.rb
rubicure-2.0.1 lib/rubicure/concerns/util.rb
rubicure-2.0.0 lib/rubicure/concerns/util.rb
rubicure-1.3.5 lib/rubicure/concerns/util.rb
rubicure-1.3.4 lib/rubicure/concerns/util.rb
rubicure-1.3.3 lib/rubicure/concerns/util.rb
rubicure-1.3.2 lib/rubicure/concerns/util.rb
rubicure-1.3.1 lib/rubicure/concerns/util.rb
rubicure-1.3.0 lib/rubicure/concerns/util.rb
rubicure-1.2.6 lib/rubicure/concerns/util.rb
rubicure-1.2.5 lib/rubicure/concerns/util.rb
rubicure-1.2.4 lib/rubicure/concerns/util.rb
rubicure-1.2.3 lib/rubicure/concerns/util.rb
rubicure-1.2.2 lib/rubicure/concerns/util.rb