From d69c8ae83238f5d3405c263052024c68b6137d81 Mon Sep 17 00:00:00 2001 From: amit-kumar27 Date: Wed, 16 Dec 2015 12:52:48 +0530 Subject: [PATCH] Update hc-utils.js method 'isValidDob' updated --- hc-utils.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hc-utils.js b/hc-utils.js index e624016..811528d 100644 --- a/hc-utils.js +++ b/hc-utils.js @@ -129,7 +129,16 @@ this.MAX_AGE = angular.isDefined(range.maxAge) ? range.maxAge : 120; } var d = this.getMomentDate(date,dateFormat), - age = moment().diff(d, 'years'); + age = moment().diff(d, 'years', true), + currentDate = new Date(), + _date = new Date(date); + + //'moment().diff()' function returns greater floating point value when dates are same + //below code will handle this case + if(currentDate.getDate() === _date.getDate()) + { + age = parseInt(age); + } return this.isValidAge(age); }, isDateAfter = function(d,date,dateFormat){