From d5c5e369653e4f5d8a53165c072ace5129ccc118 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 3 Jan 2017 11:24:14 +0100 Subject: [PATCH] [bug] compute age of users born on 29/02, lead to app crash on non-leap years --- CHANGELOG.md | 1 + app/models/profile.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71a0a2d0e..a3b767a4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/models/profile.rb b/app/models/profile.rb index 483fbee71..073ed582f 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -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