fingerpich / jalali-moment

Display, parse, manipulate, validate and convert jalali (Persian, Khorshidi, Shamsi) or Gregorian (Miladi) dates and times.
https://fingerpich.github.io/jalali-moment/
MIT License
436 stars 68 forks source link

jMoment can be called with a moment object #68

Open pouyamn opened 5 years ago

pouyamn commented 5 years ago

moment constructor do accept arrays and moment objects as input, so should jMoment

pouyamn commented 5 years ago

the test fails in cloning:

1) moment

   #clone
     clone of an invalid date is invalid:
  AssertionError: expected true to equal false
  + expected - actual
  -true
  +false

  at Context.<anonymous> (test.js:9:46665)

2) moment

clone should not affect on calendar system

     instance locale and clone:
  AssertionError: expected '1989/01/23' to equal '1367/11/03'
  + expected - actual
  -1989/01/23
  +1367/11/03

I don't know why it's happening, the problem with current code is that it destroies the input's config, if one uses a library which adds something to moment config through momentJS plugin system, the added context should be kept during cloning. An example of these libraries is full-calendar.js

Have anyone got any Ideas?