From 1f2c867028cc474d24b615587055e899b130b5d8 Mon Sep 17 00:00:00 2001 From: 6tail <6tail@6tail.cn> Date: Thu, 23 Dec 2021 19:29:26 +0800 Subject: [PATCH] =?UTF-8?q?v1.2.19=20=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=B5=B7=E8=BF=90=E9=98=B3=E5=8E=86=E6=97=A5=E6=9C=9F=E5=90=8E?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=98=9F=E6=9C=9F=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9B=E8=A1=A5=E5=85=85=E7=81=B6=E9=A9=AC?= =?UTF-8?q?=E5=A4=B4=E7=9B=B8=E5=85=B3=E5=86=85=E5=AE=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lunar.js | 70 ++++++++++++++++++++++++++++++++++++---------------- package.json | 2 +- 2 files changed, 50 insertions(+), 22 deletions(-) diff --git a/lunar.js b/lunar.js index 1b6c0f9..6781636 100644 --- a/lunar.js +++ b/lunar.js @@ -1952,33 +1952,61 @@ } return 0; }, - getZhiShui:function(){ - var offset = 4 - Solar.fromJulianDay(this.getMonth(1).getFirstJulianDay()).getLunar().getDayZhiIndex(); - if (offset < 0) { - offset += 12; - } - return LunarUtil.NUMBER[offset+1] + '龙治水'; - }, - getFenBing:function(){ - var offset = 2 - Solar.fromJulianDay(this.getMonth(1).getFirstJulianDay()).getLunar().getDayGanIndex(); + _getZaoByGan:function(index, name){ + var offset = index - Solar.fromJulianDay(this.getMonth(1).getFirstJulianDay()).getLunar().getDayGanIndex(); if (offset < 0) { offset += 10; } - return LunarUtil.NUMBER[offset+1] + '人分饼'; + return name.replace('几', LunarUtil.NUMBER[offset+1]); + }, + _getZaoByZhi:function(index, name){ + var offset = index - Solar.fromJulianDay(this.getMonth(1).getFirstJulianDay()).getLunar().getDayZhiIndex(); + if (offset < 0) { + offset += 12; + } + return name.replace('几', LunarUtil.NUMBER[offset+1]); + }, + getTouLiang:function(){ + return this._getZaoByZhi(0, '几鼠偷粮'); + }, + getCaoZi:function(){ + return this._getZaoByZhi(0, '草子几分'); }, getGengTian:function(){ - var offset = 1 - Solar.fromJulianDay(this.getMonth(1).getFirstJulianDay()).getLunar().getDayZhiIndex(); - if (offset < 0) { - offset += 12; - } - return LunarUtil.NUMBER[offset+1] + '牛耕田'; + return this._getZaoByZhi(1, '几牛耕田'); + }, + getHuaShou:function(){ + return this._getZaoByZhi(3, '花收几分'); + }, + getZhiShui:function(){ + return this._getZaoByZhi(4, '几龙治水'); + }, + getTuoGu:function(){ + return this._getZaoByZhi(6, '几马驮谷'); + }, + getQiangMi:function(){ + return this._getZaoByZhi(9, '几鸡抢米'); + }, + getKanCan:function(){ + return this._getZaoByZhi(9, '几姑看蚕'); + }, + getGongZhu:function(){ + return this._getZaoByZhi(11, '几屠共猪'); + }, + getJiaTian:function(){ + return this._getZaoByGan(0, '甲田几分'); + }, + getFenBing:function(){ + return this._getZaoByGan(2, '几人分饼'); }, getDeJin:function(){ - var offset = 7 - Solar.fromJulianDay(this.getMonth(1).getFirstJulianDay()).getLunar().getDayGanIndex(); - if (offset < 0) { - offset += 10; - } - return LunarUtil.NUMBER[offset+1] + '日得金'; + return this._getZaoByGan(7, '几日得金'); + }, + getRenBing:function(){ + return this._getZaoByGan(2, this._getZaoByZhi(2, '几人几丙')); + }, + getRenChu:function(){ + return this._getZaoByGan(3, this._getZaoByZhi(2, '几人几锄')); }, getYuan:function(){ return _YUAN[Math.floor((this._p.year+2696)/60)%3]+'元'; @@ -3343,7 +3371,7 @@ getLunar: function(){return this._p.lunar;}, getStartSolar: function(){ var birth = this._p.lunar.getSolar(); - var c = birth.getCalendar(); + var c = ExactDate.fromYmdHms(birth.getYear(), birth.getMonth(), birth.getDay(), birth.getHour(), birth.getMinute(), birth.getSecond()); c.setFullYear(birth.getYear() + this._p.startYear); c.setMonth(birth.getMonth()-1+this._p.startMonth); c.setDate(birth.getDay() + this._p.startDay); diff --git a/package.json b/package.json index c35efd9..fcb424f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lunar-javascript", - "version": "1.2.18", + "version": "1.2.19", "description": "lunar is a calendar library for Solar and Chinese Lunar.", "main": "index.js", "scripts": {