1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-30 19:52:20 +01:00

[bug] compute age of users born on 29/02, lead to app crash on non-leap years

This commit is contained in:
Sylvain 2017-01-03 11:24:14 +01:00
parent 94abdb9eec
commit d5c5e36965
2 changed files with 2 additions and 1 deletions

View File

@ -4,6 +4,7 @@
- Mask new notifications alerts when more than 3
- Fix a bug: display more than 15 unread notifications (number on the bell icon & full list)
- Fix a bug: in invoice configuration panel, VAT amount and total excl. taxes are inverted
- Fix a bug: unable to compute user's age when they were born on february 29th and current year is not a leap year
## v2.4.8 2016 December 15

View File

@ -28,7 +28,7 @@ class Profile < ActiveRecord::Base
def age
if birthday.present?
now = Time.now.utc.to_date
now.year - birthday.year - (birthday.to_date.change(:year => now.year) > now ? 1 : 0)
(now - birthday).to_f / 365.2425
else
''
end