babakhani / PersianDate

javascript date library for parsing, validating, manipulating, and formatting persian dates System.
http://babakhani.github.io/PersianWebToolkit/doc/persian-date/
Other
558 stars 100 forks source link

"toCalendar" not working #60

Closed ttvd94 closed 5 years ago

ttvd94 commented 5 years ago

Using version 1.0.5, toCalendar not working correctly. I need to convert Gregorian to Persian date but the same Gregorian date is returned.

var date = new persianDate([2018]).toCalendar('persian').format('YYYY');
// Output is ۲۰۱۸
babakhani commented 5 years ago

this statement var date = new persianDate([2018]) return Persian date. you convert it to Persian calendar again and the result is the same

ttvd94 commented 5 years ago

Apparently result is not the same, but even wrong. Since the Persian match for Gregorian-2018 would be like 1397, so the expected output is ۱۳۹۷