fingerpich / jalali-moment

Display, parse, manipulate, validate and convert jalali (Persian, Khorshidi, Shamsi) or Gregorian (Miladi) dates and times.

Home Page:https://fingerpich.github.io/jalali-moment/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Date is converted wrongly to gregorian when locale is set to "en"

amirzenoozi opened this issue · comments

Describe the bug
I have an angular pipe with this package when I update from v3.2.1 to version v3.3.1 the gregorian date not working anymore. what should I do?

Example
I have this timestamp 2020-01-19T09:18:02.207756+00:00 and I want to show 2020 Jan 19 but when I use this below code I get this result 2641 Apr 8

Moment( date ).locale( 'en' ).format( 'YYYY MMM D' );
// This code Return : 2641 Apr 8 in v3.3.1

confirm.
moment.from("2017-11-11" ,"en"); // return 2017+621 years
it must minus -621 years but instead it'll add +621 years to 2017

confirm.
moment.from("2017-11-11" ,"en"); // return 2017+621 years
it must minus -621 years but instead it'll add +621 years to 2017

passing string date to javascript Date solves the problem.

moment(Date.parse("2017-11-11")).format('jYYYY/jMM/jDD')

You have used jmoment.locale('fa') before this code so the input is read as a jalali time but you gave it a miladi time. so it will return 2641 Apr 8.
if you want to keep jmoment.locale('fa') you can use jmoment.from('2020-02-11', 'en', 'YYYY-MM-DD') to read a miladi date.

please take a look at the demo
I will close the issue and if you still have problem please create an issue which contains a demo.