MasoudBimar / PrimeNg-Persian-Calendar

Persian Calendar for PrimeNg Calendar using Moment js, Jalali Moment and Angular 7
https://MasoudBimar.github.io/PrimeNg-Persian-Calendar/
11 stars 7 forks source link

Invalid dates #1

Closed irsama closed 5 years ago

irsama commented 5 years ago

Hi, this component is worthy, but when select some dates like '1398/04/31' it displayed 'NaN/NaN/NaN', because it's invalid in gregorian date.

irsama commented 5 years ago

I found an easy solution, for solve "invalid date" problem for some jalali date like '1398/04/31'. it's enough to replace this line let date = moment([dateMeta.year, dateMeta.month, dateMeta.day]); in "selectDate" function with two below line

const jDate = moment(dateMeta.year + '/' + (dateMeta.month + 1) + '/' + dateMeta.day, 'jYYYY/jM/jD').format('YYYY/MM/DD');
let date = moment(jDate, 'YYYY/MM/DD').locale('fa');