From 83d7ee9921ed6d111ae00c19aabd488a68160c51 Mon Sep 17 00:00:00 2001 From: Pouya MN Date: Tue, 2 Jul 2019 02:25:54 +0430 Subject: [PATCH 1/2] jMoment can be called with a moment object moment constructor do accept arrays and moment objects as input, so should jMoment --- jalali-moment.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/jalali-moment.js b/jalali-moment.js index 1e251de..9dbec82 100644 --- a/jalali-moment.js +++ b/jalali-moment.js @@ -573,6 +573,20 @@ function makeMoment(input, format, lang, strict, utc) { strict = lang; lang = undefined; } + if (moment0.isMoment(input)) { + let config = input; // more understandable name + m = moment(config); + m._jDiff = config._jDiff || 0; + jm = objectCreate(jMoment.fn); + extend(jm, m); + if (strict && jm.isValid()) { + format = typeof format === 'string' ? format : "jYYYY-jMM-jDD HH:mm:ss" //fails if format is array + jm._isValid = jm.format(format) === input.format(format); + } + + return jm; + } + var itsJalaliDate = (isJalali(this)); if(input && (typeof input === "string") && !format && itsJalaliDate && !moment.useGregorianParser) { input = input.replace(/\//g,"-"); From 101c19968c4db54a26cfe0f1674807549de746ce Mon Sep 17 00:00:00 2001 From: Pouya MN Date: Tue, 2 Jul 2019 02:39:28 +0430 Subject: [PATCH 2/2] fixing typo --- jalali-moment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jalali-moment.js b/jalali-moment.js index 9dbec82..a85dbe0 100644 --- a/jalali-moment.js +++ b/jalali-moment.js @@ -573,7 +573,7 @@ function makeMoment(input, format, lang, strict, utc) { strict = lang; lang = undefined; } - if (moment0.isMoment(input)) { + if (moment.isMoment(input)) { let config = input; // more understandable name m = moment(config); m._jDiff = config._jDiff || 0;