From aa386154bf28ebf171478d09e30bc0c1cbdf4d65 Mon Sep 17 00:00:00 2001 From: 6tail <6tail@6tail.cn> Date: Thu, 19 Nov 2020 12:18:32 +0800 Subject: [PATCH] =?UTF-8?q?v1.0.29=20=E6=96=B0=E5=A2=9E=E6=97=AC=E3=80=81?= =?UTF-8?q?=E6=97=AC=E7=A9=BA(=E7=A9=BA=E4=BA=A1)=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lunar.js | 106 ++++++++++++++++++++++++++++++++++++++++++++++++--- package.json | 2 +- 2 files changed, 102 insertions(+), 6 deletions(-) diff --git a/lunar.js b/lunar.js index 121f80f..4a59658 100644 --- a/lunar.js +++ b/lunar.js @@ -1528,6 +1528,54 @@ } return _fromYmdHms(y,m,d,this._p.hour,this._p.minute,this._p.second); }, + getYearXun:function(){ + return LunarUtil.getXun(this.getYearInGanZhi()); + }, + getMonthXun:function(){ + return LunarUtil.getXun(this.getMonthInGanZhi()); + }, + getDayXun:function(){ + return LunarUtil.getXun(this.getDayInGanZhi()); + }, + getTimeXun:function(){ + return LunarUtil.getXun(this.getTimeInGanZhi()); + }, + getYearXunByLiChun:function(){ + return LunarUtil.getXun(this.getYearInGanZhiByLiChun()); + }, + getYearXunExact:function(){ + return LunarUtil.getXun(this.getYearInGanZhiExact()); + }, + getMonthXunExact:function(){ + return LunarUtil.getXun(this.getMonthInGanZhiExact()); + }, + getDayXunExact:function(){ + return LunarUtil.getXun(this.getDayInGanZhiExact()); + }, + getYearXunKong:function(){ + return LunarUtil.getXunKong(this.getYearInGanZhi()); + }, + getMonthXunKong:function(){ + return LunarUtil.getXunKong(this.getMonthInGanZhi()); + }, + getDayXunKong:function(){ + return LunarUtil.getXunKong(this.getDayInGanZhi()); + }, + getTimeXunKong:function(){ + return LunarUtil.getXunKong(this.getTimeInGanZhi()); + }, + getYearXunKongByLiChun:function(){ + return LunarUtil.getXunKong(this.getYearInGanZhiByLiChun()); + }, + getYearXunKongExact:function(){ + return LunarUtil.getXunKong(this.getYearInGanZhiExact()); + }, + getMonthXunKongExact:function(){ + return LunarUtil.getXunKong(this.getMonthInGanZhiExact()); + }, + getDayXunKongExact:function(){ + return LunarUtil.getXunKong(this.getDayInGanZhiExact()); + }, toString:function(){ return this.getYearInChinese()+'年'+this.getMonthInChinese()+'月'+this.getDayInChinese(); }, @@ -2017,6 +2065,8 @@ BASE_DAY_GANZHI_INDEX:15, BASE_MONTH_ZHI_INDEX:2, BASE_WEEK_INDEX:2, + XUN:['甲子','甲戌','甲申','甲午','甲辰','甲寅'], + XUN_KONG:['戌亥','申酉','午未','辰巳','寅卯','子丑'], GAN:['','甲','乙','丙','丁','戊','己','庚','辛','壬','癸'], POSITION_XI:['','艮','乾','坤','离','巽','艮','乾','坤','离','巽'], POSITION_YANG_GUI:['','坤','坤','兑','乾','艮','坎','离','艮','震','巽'], @@ -2329,6 +2379,36 @@ l.push('无'); } return l; + }, + getXunIndex:function(ganZhi){ + var gan = ganZhi.substr(0,1); + var zhi = ganZhi.substr(1); + var ganIndex = 0; + var zhiIndex = 0; + var i,j; + for(i=0,j=this.GAN.length;i=10){ @@ -2846,9 +2934,9 @@ index: index, liuNian: liuNian }, - getIndex: function(){return this._p.index;}, - getMonthInChinese: function(){return LunarUtil.MONTH[this._p.index + 1];}, - getGanZhi: function(){ + getIndex:function(){return this._p.index;}, + getMonthInChinese:function(){return LunarUtil.MONTH[this._p.index + 1];}, + getGanZhi:function(){ var offset = 0; var yearGan = liuNian.getGanZhi().substr(0, 1); if ('甲'===yearGan || '己'===yearGan) { @@ -2863,7 +2951,9 @@ var gan = LunarUtil.GAN[(this._p.index + offset) % 10 + 1]; var zhi = LunarUtil.ZHI[(this._p.index + LunarUtil.BASE_MONTH_ZHI_INDEX) % 12 + 1]; return gan + zhi; - } + }, + getXun:function(){return LunarUtil.getXun(this.getGanZhi());}, + getXunKong:function(){return LunarUtil.getXunKong(this.getGanZhi());} }; }; var buildLiuNian = function(daYun, index){ @@ -2887,6 +2977,8 @@ offset %= LunarUtil.JIA_ZI.length; return LunarUtil.JIA_ZI[offset]; }, + getXun:function(){return LunarUtil.getXun(this.getGanZhi());}, + getXunKong:function(){return LunarUtil.getXunKong(this.getGanZhi());}, getLiuYue: function(){ var n = 12; var l = []; @@ -2923,7 +3015,9 @@ } offset %= size; return LunarUtil.JIA_ZI[offset]; - } + }, + getXun:function(){return LunarUtil.getXun(this.getGanZhi());}, + getXunKong:function(){return LunarUtil.getXunKong(this.getGanZhi());} }; }; var buildDaYun = function(yun, index){ @@ -2973,6 +3067,8 @@ } return LunarUtil.JIA_ZI[offset]; }, + getXun:function(){return LunarUtil.getXun(this.getGanZhi());}, + getXunKong:function(){return LunarUtil.getXunKong(this.getGanZhi());}, getLiuNian: function(){ var n = 10; if (this._p.index < 1) { diff --git a/package.json b/package.json index d74e4f7..cbf0ad9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lunar-javascript", - "version": "1.0.28", + "version": "1.0.29", "description": "lunar is a calendar library for Solar and Chinese Lunar.", "main": "index.js", "scripts": {