From 7b688702f3d760098a2dc837532368abcfa75318 Mon Sep 17 00:00:00 2001 From: yuweiqi Date: Mon, 25 May 2020 13:59:48 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E3=80=90=E9=80=9A=E7=94=A8=E5=B9=B4?= =?UTF-8?q?=E9=BE=84=E6=A0=A1=E9=AA=8C=E6=96=B9=E6=B3=95=E3=80=91src/asset?= =?UTF-8?q?s/js/utils/age.js=E6=96=87=E4=BB=B6getDateDiff=EF=BC=88?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E4=B8=A4=E4=B8=AA=E6=97=A5=E6=9C=9F=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=B7=AE=EF=BC=89=E6=96=B9=E6=B3=95=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/js/utils/age.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/assets/js/utils/age.js b/src/assets/js/utils/age.js index 373a426ee..69eb43fbd 100644 --- a/src/assets/js/utils/age.js +++ b/src/assets/js/utils/age.js @@ -1,12 +1,12 @@ export default { - getAge: function (name, today) { + getAge: function(name, today) { return this.getAgeByValue(name, today) }, - getAgeByBirth: function (value, today) { + getAgeByBirth: function(value, today) { return this.getAgeByValue(value, today) }, - getAgeByValue: function (value, today) { + getAgeByValue: function(value, today) { var b = value.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/) if (b == null) { return null @@ -33,7 +33,7 @@ export default { /** * 取得两个日期的时间差 */ - getDateDiff: function (date1, date2) { + getDateDiff: function(date1, date2) { var dt1, dt2 if (date1 instanceof Date) { dt1 = date1 @@ -45,13 +45,14 @@ export default { } else { dt2 = this.stringToDate(date2) } - return (dt2.getTime() - dt1.getTime()) / (1000 * 3600 * 24) + 1 + return (dt2.getTime() - dt1.getTime()) / (1000 * 3600 * 24) + // return (dt2.getTime() - dt1.getTime()) / (1000 * 3600 * 24) + 1 }, /** * 字符串转日期 */ - stringToDate: function (string) { + stringToDate: function(string) { return new Date(Date.parse(string.replace(/-/g, '/'))) } }