From 584662a3bb911d8611299fc2d7fb560ecab682b0 Mon Sep 17 00:00:00 2001 From: mo khan Date: Thu, 27 Feb 2014 18:26:23 -0700 Subject: fix bug related to expiration time boundaries. apparently time is a moving target. --- app/models/license_status/active.rb | 8 ++++---- app/models/license_status/expired.rb | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/models/license_status/active.rb b/app/models/license_status/active.rb index f959efb..512fff9 100644 --- a/app/models/license_status/active.rb +++ b/app/models/license_status/active.rb @@ -1,7 +1,7 @@ class LicenseStatus::Active def filter(licenses) - today = Date.today - licenses.where('issued_at < ? AND expired_at > ?', today, today) + now = DateTime.now + licenses.where('issued_at < ? AND expired_at > ?', now, now) end def matches?(name) @@ -9,8 +9,8 @@ class LicenseStatus::Active end def best_represents?(license) - today = Date.today - license.issued_at < today && license.expired_at > today + now = DateTime.now + license.issued_at < now && license.expired_at > now end def to_s diff --git a/app/models/license_status/expired.rb b/app/models/license_status/expired.rb index 8e24af9..9bbdf4b 100644 --- a/app/models/license_status/expired.rb +++ b/app/models/license_status/expired.rb @@ -1,7 +1,6 @@ class LicenseStatus::Expired def filter(licenses) - today = DateTime.now - licenses.where('expired_at < ?', today) + licenses.where('expired_at < ?', DateTime.now) end def matches?(name) @@ -9,7 +8,7 @@ class LicenseStatus::Expired end def best_represents?(license) - license.expired_at < Date.today + license.expired_at < DateTime.now end def to_s -- cgit v1.2.3