Sha256: 42ed5572dce34ab490791665e12cdfeb2e2ecd2dbe3301841fbd44407f580fdb

Contents?: true

Size: 748 Bytes

Versions: 167

Compression:

Stored size: 748 Bytes

Contents

require 'date'

module ActiveMerchant
  module Billing
    class CreditCard
      class ExpiryDate #:nodoc:
        attr_reader :month, :year
        def initialize(month, year)
          @month = month.to_i
          @year = year.to_i
        end
        
        def expired? #:nodoc:
          Time.now.utc > expiration
        end
        
        def expiration #:nodoc:
          begin
            Time.utc(year, month, month_days, 23, 59, 59)
          rescue ArgumentError
            Time.at(0).utc
          end
        end
        
        private
        def month_days
          mdays = [nil,31,28,31,30,31,30,31,31,30,31,30,31]
          mdays[2] = 29 if Date.leap?(year)
          mdays[month]
        end
      end
    end
  end
end

Version data entries

167 entries across 167 versions & 33 rubygems

Version Path
tanga_activemerchant-1.38.0.5 lib/active_merchant/billing/expiry_date.rb
tanga_activemerchant-1.38.0.4 lib/active_merchant/billing/expiry_date.rb
tanga_activemerchant-1.38.0.3 lib/active_merchant/billing/expiry_date.rb
tanga_activemerchant-1.38.0.2 lib/active_merchant/billing/expiry_date.rb
tanga_activemerchant-1.38.0.1 lib/active_merchant/billing/expiry_date.rb
tanga_activemerchant-1.38.0 lib/active_merchant/billing/expiry_date.rb
tanga_activemerchant-1.37.0 lib/active_merchant/billing/expiry_date.rb
johnideal-activemerchant-1.4.10 lib/active_merchant/billing/expiry_date.rb
johnideal-activemerchant-1.4.11 lib/active_merchant/billing/expiry_date.rb
johnideal-activemerchant-1.4.4 lib/active_merchant/billing/expiry_date.rb
johnideal-activemerchant-1.4.5 lib/active_merchant/billing/expiry_date.rb
johnideal-activemerchant-1.4.6 lib/active_merchant/billing/expiry_date.rb
johnideal-activemerchant-1.4.7 lib/active_merchant/billing/expiry_date.rb
johnideal-activemerchant-1.4.8 lib/active_merchant/billing/expiry_date.rb
mattbauer-activemerchant-1.4.2 lib/active_merchant/billing/expiry_date.rb
tomriley-active_merchant-1.4.2.4 lib/active_merchant/billing/expiry_date.rb
tomriley-active_merchant-1.4.2.5 lib/active_merchant/billing/expiry_date.rb
tomriley-active_merchant-1.4.2.6 lib/active_merchant/billing/expiry_date.rb
tomriley-active_merchant-1.4.2.7 lib/active_merchant/billing/expiry_date.rb
tomriley-active_merchant-1.4.2.8 lib/active_merchant/billing/expiry_date.rb