From 94a700479f2ee8bfbf746b8d11a753de69472016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B2=81=E6=9C=88=E5=B0=8F=E5=81=B7?= <470459819@qq.com> Date: Sun, 10 Jul 2022 12:33:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dlaydate=E5=9C=A8=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=80=BC=E7=9A=84=E6=97=B6=E5=88=86=E7=A7=92=E5=AD=98?= =?UTF-8?q?=E5=9C=A800=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=83=85=E5=86=B5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/laydate.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/modules/laydate.js b/src/modules/laydate.js index 9bdb387a..ff8058ab 100644 --- a/src/modules/laydate.js +++ b/src/modules/laydate.js @@ -621,10 +621,10 @@ ,checkValid = function(dateTime){ if(dateTime.year > LIMIT_YEAR[1]) dateTime.year = LIMIT_YEAR[1], error = true; //不能超过20万年 if(dateTime.month > 11) dateTime.month = 11, error = true; - if(dateTime.hours > 23) dateTime.hours = 0, error = true; - if(dateTime.minutes > 59) dateTime.minutes = 0, dateTime.hours++, error = true; if(dateTime.seconds > 59) dateTime.seconds = 0, dateTime.minutes++, error = true; - + if(dateTime.minutes > 59) dateTime.minutes = 0, dateTime.hours++, error = true; + if(dateTime.hours > 23) dateTime.hours = 0, error = true; + //计算当前月的最后一天 thisMaxDate = laydate.getEndDate(dateTime.month + 1, dateTime.year); if(dateTime.date > thisMaxDate) dateTime.date = thisMaxDate, error = true; @@ -652,15 +652,18 @@ if(thisv < 1) thisv = 1, error = true; dateTime.date = thisv; } else if(/HH|H/.test(item)){ //时 - if(thisv < 1) thisv = 0, error = true; + if (thisv < 0) thisv = 0, error = true; + if (thisv > 23) thisv = 23, error = true; dateTime.hours = thisv; options.range && (that[startEnd[index]].hours = thisv); } else if(/mm|m/.test(item)){ //分 - if(thisv < 1) thisv = 0, error = true; + if (thisv < 0) thisv = 0, error = true; + if (thisv > 59) thisv = 59, error = true; dateTime.minutes = thisv; options.range && (that[startEnd[index]].minutes = thisv); } else if(/ss|s/.test(item)){ //秒 - if(thisv < 1) thisv = 0, error = true; + if (thisv < 0) thisv = 0, error = true; + if (thisv > 59) thisv = 59, error = true; dateTime.seconds = thisv; options.range && (that[startEnd[index]].seconds = thisv); }