From 0689a7732af28fd278c44baf60d834e9dd7a32db Mon Sep 17 00:00:00 2001 From: Mohammad Amanalikhani Date: Sat, 25 Nov 2023 13:16:29 +0330 Subject: [PATCH] =?UTF-8?q?fix(solar):=20=D8=A7=D8=B5=D9=84=D8=A7=D8=AD=20?= =?UTF-8?q?=D9=88=D8=B1=D9=88=D8=AF=DB=8C=20month>11=20||=20month<0=20?= =?UTF-8?q?=D8=A8=D8=B1=D8=A7=DB=8C=20=D8=AA=D8=A8=D8=AF=DB=8C=D9=84=20?= =?UTF-8?q?=D8=B4=D9=85=D8=B3=DB=8C=20=D8=A8=D9=87=20=D9=82=D9=85=D8=B1?= =?UTF-8?q?=DB=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MD Amanalikhani --- src/base.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/base.ts b/src/base.ts index 46f13ca..7bc687e 100644 --- a/src/base.ts +++ b/src/base.ts @@ -214,17 +214,17 @@ export default class SHDate { /** * Convert gregorian date to solar hijri date - * @param {number} g_year - gregorian year - * @param {number} g_month - gregorian month - * @param {number} g_date - gregorian date - * @param {boolean} julian - julian date + * @param {number} gyear - gregorian year + * @param {number} gmonth - gregorian month + * @param {number} gdate - gregorian date + * @param {boolean} is_julian - julian date (default: false) * @returns {array} - solar hijri date */ #GregorianToSolar( gyear: number, gmonth: number, gdate: number, - julian: boolean = false + is_julian: boolean = false ): number[] { // 0622/03/22 = 0001/01/01 var gdoy: number = @@ -243,19 +243,20 @@ export default class SHDate { * @param {number} s_year - solar hijri year * @param {number} s_month - solar hijri month * @param {number} s_date - solar hijri date - * @param {boolean} julian - julian date + * @param {boolean} is_julian - julian date (default: false) * @returns {array} - gregorian date */ #SolarToGregorian( s_year: number, s_month: number, s_date: number, - julian: boolean = false + is_julian: boolean = false ): number[] { // 0001/01/01 = 0622/03/22 - const [syear, smonth, sdate] = this.checkDate(s_year, s_month, s_date) - ? [s_year, s_month, s_date] - : this.dateCorrection(s_year, s_month, s_date); + const [syear, smonth, sdate] = + s_month < 0 || s_month > 11 + ? this.dateCorrection(s_year, s_month, s_date) + : [s_year, s_month, s_date]; const sdoy = (syear - 1) * 365 + this.#dayOfYear(smonth, sdate) +