From b926be00222a2c583caefdba90103fafe8e20bb9 Mon Sep 17 00:00:00 2001 From: 6tail <6tail@6tail.cn> Date: Mon, 6 Feb 2023 21:05:44 +0800 Subject: [PATCH] =?UTF-8?q?v1.3.1=20=E4=BF=AE=E5=A4=8D=E5=85=AB=E5=AD=97?= =?UTF-8?q?=E8=BD=AC=E9=98=B3=E5=8E=86=E6=9E=81=E7=AB=AF=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E4=BB=8D=E7=84=B6=E6=9C=89=E9=81=97=E6=BC=8F=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __tests__/EightChar.test.js | 4 ++++ lunar.js | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/__tests__/EightChar.test.js b/__tests__/EightChar.test.js index 8929c3e..f05f03b 100644 --- a/__tests__/EightChar.test.js +++ b/__tests__/EightChar.test.js @@ -177,3 +177,7 @@ test('test11', () => { expect(eightChar.getDay()).toBe('庚子'); expect(eightChar.getTime()).toBe('戊子'); }); + +test('test12', () => { + expect(Solar.fromYmdHms('1999', '06', '07', '09', '11', '00').getLunar().getEightChar().toString()).toBe('己卯 庚午 庚寅 辛巳'); +}); diff --git a/lunar.js b/lunar.js index 7d7129d..ae21983 100644 --- a/lunar.js +++ b/lunar.js @@ -514,9 +514,13 @@ offsetYear += 60; } var startYear = today.getYear() - offsetYear - 1; - while (startYear >= baseYear) { + while (true) { years.push(startYear); startYear -= 60; + if (startYear < baseYear) { + years.push(baseYear); + break; + } } var hour = 0; var timeZhi = timeGanZhi.substr(1);