From 4c4bad62c31ff0eba33ef726ba56f4a58d2c97bc Mon Sep 17 00:00:00 2001 From: kekeh Date: Sun, 11 Apr 2021 13:39:26 +0300 Subject: [PATCH] Fixed bug: Date & Month defaulting to current month and Date #79. --- CHANGELOG.md | 4 +--- package.json | 2 +- projects/angular-mydatepicker/package.json | 2 +- .../lib/services/angular-mydatepicker.util.service.ts | 11 ++++++----- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b4f04d..79871e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -811,7 +811,7 @@ * Peer dependencies removed from the package.json file. -# 0.11.1 (2021-04-11) +# 0.11.2 (2021-04-11) ### Bug Fixes @@ -820,5 +820,3 @@ ### Features * none - - diff --git a/package.json b/package.json index e29c853..5eae262 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-mydatepicker-example", - "version": "0.11.1", + "version": "0.11.2", "description": "Angular datepicker and date range picker", "homepage": "https://kekeh.github.io/angular-mydatepicker/", "keywords": [ diff --git a/projects/angular-mydatepicker/package.json b/projects/angular-mydatepicker/package.json index 002888c..da90ddf 100644 --- a/projects/angular-mydatepicker/package.json +++ b/projects/angular-mydatepicker/package.json @@ -1,6 +1,6 @@ { "name": "angular-mydatepicker", - "version": "0.11.1", + "version": "0.11.2", "description": "Angular datepicker and date range picker", "homepage": "https://kekeh.github.io/angular-mydatepicker/", "keywords": [ diff --git a/projects/angular-mydatepicker/src/lib/services/angular-mydatepicker.util.service.ts b/projects/angular-mydatepicker/src/lib/services/angular-mydatepicker.util.service.ts index 1713ac8..68d8463 100644 --- a/projects/angular-mydatepicker/src/lib/services/angular-mydatepicker.util.service.ts +++ b/projects/angular-mydatepicker/src/lib/services/angular-mydatepicker.util.service.ts @@ -38,7 +38,12 @@ export class UtilService { let day: number = 0; for(const dv of dateValues) { - const {format} = dv; + const {value, format} = dv; + + if (value && /^\d+$/.test(value) && Number(value) === 0) { + return returnDate; + } + if (format.indexOf(YYYY) !== -1) { year = this.getNumberByValue(dv); } @@ -50,10 +55,6 @@ export class UtilService { } } - if (year === 0 || month === 0 || day === 0) { - return returnDate; - } - const {validateDisabledDates, selectedValue} = validateOpts; year = year === 0 && selectedValue ? selectedValue.year : year;