lib/active_merchant/billing/expiry_date.rb in activemerchant-1.4.2 vs lib/active_merchant/billing/expiry_date.rb in activemerchant-1.5.0
- old
+ new
@@ -1,20 +1,26 @@
+require 'date'
+
module ActiveMerchant
module Billing
class CreditCard
class ExpiryDate #:nodoc:
attr_reader :month, :year
def initialize(month, year)
- @month = month
- @year = year
+ @month = month.to_i
+ @year = year.to_i
end
def expired? #:nodoc:
- Time.now > expiration rescue true
+ Time.now.utc > expiration
end
def expiration #:nodoc:
- Time.parse("#{month}/#{month_days}/#{year} 23:59:59") rescue Time.at(0)
+ 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]
\ No newline at end of file