Sha256: 76ffb774e8191b353907cd3459ac3d1694c4c15cc234b22224f27b65cda422de

Contents?: true

Size: 666 Bytes

Versions: 11

Compression:

Stored size: 666 Bytes

Contents

module ActiveMerchant
  module Billing
    class CreditCard
      class ExpiryDate #:nodoc:
        attr_reader :month, :year
        def initialize(month, year)
          @month = month
          @year = year
        end
        
        def expired? #:nodoc:
          Time.now > expiration rescue true
        end
        
        def expiration #:nodoc:
          Time.parse("#{month}/#{month_days}/#{year} 23:59:59") rescue Time.at(0)
        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

11 entries across 11 versions & 5 rubygems

Version Path
martinstannard-activemerchant-0.1.0 lib/active_merchant/billing/expiry_date.rb
seamusabshere-active_merchant-1.4.2.1 lib/active_merchant/billing/expiry_date.rb
seamusabshere-active_merchant-1.4.2.3 lib/active_merchant/billing/expiry_date.rb
tomriley-active_merchant-1.4.2.3 lib/active_merchant/billing/expiry_date.rb
activemerchant-1.4.1 lib/active_merchant/billing/expiry_date.rb
activemerchant-1.3.2 lib/active_merchant/billing/expiry_date.rb
activemerchant-1.4.0 lib/active_merchant/billing/expiry_date.rb
activemerchant-1.3.1 lib/active_merchant/billing/expiry_date.rb
activemerchant-1.3.0 lib/active_merchant/billing/expiry_date.rb
activemerchant-1.4.2 lib/active_merchant/billing/expiry_date.rb
spree-0.2.0 vendor/plugins/active_merchant/lib/active_merchant/billing/expiry_date.rb