Sha256: 669aedd23edd69a022150f4c3c5da72e88e92d39d14e0a2263b1f4a206714a8f

Contents?: true

Size: 489 Bytes

Versions: 11

Compression:

Stored size: 489 Bytes

Contents

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rubicure-1.2.1 lib/rubicure/concerns/util.rb
rubicure-1.2.0 lib/rubicure/concerns/util.rb
rubicure-1.1.10 lib/rubicure/concerns/util.rb
rubicure-1.1.9 lib/rubicure/concerns/util.rb
rubicure-1.1.8 lib/rubicure/concerns/util.rb
rubicure-1.1.7 lib/rubicure/concerns/util.rb
rubicure-1.1.6 lib/rubicure/concerns/util.rb
rubicure-1.1.5 lib/rubicure/concerns/util.rb
rubicure-1.1.4 lib/rubicure/concerns/util.rb
rubicure-1.1.3 lib/rubicure/concerns/util.rb
rubicure-1.1.2 lib/rubicure/concerns/util.rb