@unicom-cloud/utils 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,11 @@
1
- import { LunarUtil as e } from "./LunarUtil.js";
2
- import { LunarYear as _ } from "./LunarYear.js";
3
- import { Solar as O } from "./Solar.js";
4
- class m {
5
- _year;
6
- _month;
7
- _dayCount;
8
- _firstJulianDay;
9
- _index;
10
- _zhiIndex;
11
- static fromYm(t, i) {
12
- return _.fromYear(t).getMonth(i);
1
+ import { LunarUtil as m } from "./LunarUtil.js";
2
+ import { LunarYear as f } from "./LunarYear.js";
3
+ class l {
4
+ static fromYm(n, t) {
5
+ return f.fromYear(n).getMonth(t);
13
6
  }
14
- constructor(t, i, s, h, o) {
15
- this._year = t, this._month = i, this._dayCount = s, this._firstJulianDay = h, this._index = o, this._zhiIndex = (o - 1 + e.BASE_MONTH_ZHI_INDEX) % 12;
7
+ constructor(n, t, i, a, h) {
8
+ this._year = n, this._month = t, this._dayCount = i, this._firstJulianDay = a, this._index = h, this._zhiIndex = (h - 1 + m.BASE_MONTH_ZHI_INDEX) % 12;
16
9
  }
17
10
  getYear() {
18
11
  return this._year;
@@ -24,17 +17,17 @@ class m {
24
17
  return this._index;
25
18
  }
26
19
  getGanIndex() {
27
- const t = (_.fromYear(this._year).getGanIndex() + 1) % 5 * 2;
28
- return (this._index - 1 + t) % 10;
20
+ const n = (f.fromYear(this._year).getGanIndex() + 1) % 5 * 2;
21
+ return (this._index - 1 + n) % 10;
29
22
  }
30
23
  getZhiIndex() {
31
24
  return this._zhiIndex;
32
25
  }
33
26
  getGan() {
34
- return e.GAN[this.getGanIndex() + 1];
27
+ return m.GAN[this.getGanIndex() + 1];
35
28
  }
36
29
  getZhi() {
37
- return e.ZHI[this._zhiIndex + 1];
30
+ return m.ZHI[this._zhiIndex + 1];
38
31
  }
39
32
  getGanZhi() {
40
33
  return this.getGan() + this.getZhi();
@@ -48,103 +41,47 @@ class m {
48
41
  getFirstJulianDay() {
49
42
  return this._firstJulianDay;
50
43
  }
51
- getPositionXi() {
52
- return e.POSITION_XI[this.getGanIndex() + 1];
53
- }
54
- getPositionXiDesc() {
55
- return e.POSITION_DESC[this.getPositionXi()];
56
- }
57
- getPositionYangGui() {
58
- return e.POSITION_YANG_GUI[this.getGanIndex() + 1];
59
- }
60
- getPositionYangGuiDesc() {
61
- return e.POSITION_DESC[this.getPositionYangGui()];
62
- }
63
- getPositionYinGui() {
64
- return e.POSITION_YIN_GUI[this.getGanIndex() + 1];
65
- }
66
- getPositionYinGuiDesc() {
67
- return e.POSITION_DESC[this.getPositionYinGui()];
68
- }
69
- getPositionFu(t = 2) {
70
- return (t == 1 ? e.POSITION_FU : e.POSITION_FU_2)[this.getGanIndex() + 1];
71
- }
72
- getPositionFuDesc(t = 2) {
73
- return e.POSITION_DESC[this.getPositionFu(t)];
74
- }
75
- getPositionCai() {
76
- return e.POSITION_CAI[this.getGanIndex() + 1];
77
- }
78
- getPositionCaiDesc() {
79
- return e.POSITION_DESC[this.getPositionCai()];
80
- }
81
- getPositionTaiSui() {
82
- let t;
83
- switch (Math.abs(this._month)) {
84
- case 1:
85
- case 5:
86
- case 9:
87
- t = "艮";
88
- break;
89
- case 3:
90
- case 7:
91
- case 11:
92
- t = "坤";
93
- break;
94
- case 4:
95
- case 8:
96
- case 12:
97
- t = "巽";
98
- break;
99
- default:
100
- t = e.POSITION_GAN[O.fromJulianDay(this.getFirstJulianDay()).getLunar().getMonthGanIndex()];
101
- }
102
- return t;
103
- }
104
- getPositionTaiSuiDesc() {
105
- return e.POSITION_DESC[this.getPositionTaiSui()];
106
- }
107
44
  toString() {
108
- return `${this.getYear()}年${this.isLeap() ? "闰" : ""}${e.MONTH[Math.abs(this.getMonth())]}月(${this.getDayCount()})天`;
45
+ return `${this.getYear()}年${this.isLeap() ? "闰" : ""}${m.MONTH[Math.abs(this.getMonth())]}月(${this.getDayCount()})天`;
109
46
  }
110
- next(t) {
111
- if (t == 0)
112
- return m.fromYm(this._year, this._month);
47
+ next(n) {
48
+ if (n == 0)
49
+ return l.fromYm(this._year, this._month);
113
50
  {
114
- let i = Math.abs(t), s = this._year, h = s, o = this._month, a = 0, n = _.fromYear(s).getMonths(), r, g, u;
115
- if (t > 0) {
51
+ let t = Math.abs(n), i = this._year, a = i, h = this._month, s = 0, e = f.fromYear(i).getMonths(), r, o, g;
52
+ if (n > 0) {
116
53
  for (; ; ) {
117
- for (u = n.length, r = 0; r < u; r++)
118
- if (g = n[r], g.getYear() === h && g.getMonth() === o) {
119
- a = r;
54
+ for (g = e.length, r = 0; r < g; r++)
55
+ if (o = e[r], o.getYear() === a && o.getMonth() === h) {
56
+ s = r;
120
57
  break;
121
58
  }
122
- const I = u - a - 1;
123
- if (i < I)
59
+ const u = g - s - 1;
60
+ if (t < u)
124
61
  break;
125
- i -= I;
126
- const P = n[u - 1];
127
- h = P.getYear(), o = P.getMonth(), s++, n = _.fromYear(s).getMonths();
62
+ t -= u;
63
+ const _ = e[g - 1];
64
+ a = _.getYear(), h = _.getMonth(), i++, e = f.fromYear(i).getMonths();
128
65
  }
129
- return n[a + i];
66
+ return e[s + t];
130
67
  } else {
131
68
  for (; ; ) {
132
- for (u = n.length, r = 0; r < u; r++)
133
- if (g = n[r], g.getYear() === h && g.getMonth() === o) {
134
- a = r;
69
+ for (g = e.length, r = 0; r < g; r++)
70
+ if (o = e[r], o.getYear() === a && o.getMonth() === h) {
71
+ s = r;
135
72
  break;
136
73
  }
137
- if (i <= a)
74
+ if (t <= s)
138
75
  break;
139
- i -= a;
140
- const I = n[0];
141
- h = I.getYear(), o = I.getMonth(), s--, n = _.fromYear(s).getMonths();
76
+ t -= s;
77
+ const u = e[0];
78
+ a = u.getYear(), h = u.getMonth(), i--, e = f.fromYear(i).getMonths();
142
79
  }
143
- return n[a - i];
80
+ return e[s - t];
144
81
  }
145
82
  }
146
83
  }
147
84
  }
148
85
  export {
149
- m as LunarMonth
86
+ l as LunarMonth
150
87
  };
@@ -1,22 +1,19 @@
1
- import { Lunar as a } from "./Lunar.js";
2
- import { LunarUtil as t } from "./LunarUtil.js";
3
- class s {
4
- _ganIndex;
5
- _zhiIndex;
6
- _lunar;
7
- static fromYmdHms(n, e, i, r, g, h) {
8
- return new s(n, e, i, r, g, h);
9
- }
10
- constructor(n, e, i, r, g, h) {
11
- this._lunar = a.fromYmdHms(
12
- n,
13
- e,
1
+ import { Lunar as s } from "./Lunar.js";
2
+ import { LunarUtil as e } from "./LunarUtil.js";
3
+ class a {
4
+ static fromYmdHms(t, i, h, n, r, g) {
5
+ return new a(t, i, h, n, r, g);
6
+ }
7
+ constructor(t, i, h, n, r, g) {
8
+ this._lunar = s.fromYmdHms(
9
+ t,
14
10
  i,
11
+ h,
12
+ n,
15
13
  r,
16
- g,
17
- h
18
- ), this._zhiIndex = t.getTimeZhiIndex(
19
- [(r < 10 ? "0" : "") + r, (g < 10 ? "0" : "") + g].join(
14
+ g
15
+ ), this._zhiIndex = e.getTimeZhiIndex(
16
+ [(n < 10 ? "0" : "") + n, (r < 10 ? "0" : "") + r].join(
20
17
  ":"
21
18
  )
22
19
  ), this._ganIndex = (this._lunar.getDayGanIndexExact() % 5 * 2 + this._zhiIndex) % 10;
@@ -28,111 +25,35 @@ class s {
28
25
  return this._zhiIndex;
29
26
  }
30
27
  getGan() {
31
- return t.GAN[this._ganIndex + 1];
28
+ return e.GAN[this._ganIndex + 1];
32
29
  }
33
30
  getZhi() {
34
- return t.ZHI[this._zhiIndex + 1];
31
+ return e.ZHI[this._zhiIndex + 1];
35
32
  }
36
33
  getGanZhi() {
37
34
  return this.getGan() + this.getZhi();
38
35
  }
39
36
  getShengXiao() {
40
- return t.SHENGXIAO[this._zhiIndex + 1];
41
- }
42
- getPositionXi() {
43
- return t.POSITION_XI[this._ganIndex + 1];
44
- }
45
- getPositionXiDesc() {
46
- return t.POSITION_DESC[this.getPositionXi()];
47
- }
48
- getPositionYangGui() {
49
- return t.POSITION_YANG_GUI[this._ganIndex + 1];
50
- }
51
- getPositionYangGuiDesc() {
52
- return t.POSITION_DESC[this.getPositionYangGui()];
53
- }
54
- getPositionYinGui() {
55
- return t.POSITION_YIN_GUI[this._ganIndex + 1];
56
- }
57
- getPositionYinGuiDesc() {
58
- return t.POSITION_DESC[this.getPositionYinGui()];
59
- }
60
- getPositionFu(n = 2) {
61
- return (n === 1 ? t.POSITION_FU : t.POSITION_FU_2)[this._ganIndex + 1];
62
- }
63
- getPositionFuDesc(n = 2) {
64
- return t.POSITION_DESC[this.getPositionFu(n)];
65
- }
66
- getPositionCai() {
67
- return t.POSITION_CAI[this._ganIndex + 1];
68
- }
69
- getPositionCaiDesc() {
70
- return t.POSITION_DESC[this.getPositionCai()];
71
- }
72
- getNaYin() {
73
- return t.NAYIN[this.getGanZhi()];
74
- }
75
- getTianShen() {
76
- return t.TIAN_SHEN[(this._zhiIndex + t.ZHI_TIAN_SHEN_OFFSET[this._lunar.getDayZhiExact()]) % 12 + 1];
77
- }
78
- getTianShenType() {
79
- return t.TIAN_SHEN_TYPE[this.getTianShen()];
80
- }
81
- getTianShenLuck() {
82
- return t.TIAN_SHEN_TYPE_LUCK[this.getTianShenType()];
83
- }
84
- getChong() {
85
- return t.CHONG[this._zhiIndex];
86
- }
87
- getSha() {
88
- return t.SHA[this.getZhi()];
89
- }
90
- getChongShengXiao() {
91
- const n = this.getChong();
92
- for (let e = 0, i = t.ZHI.length; e < i; e++)
93
- if (t.ZHI[e] === n)
94
- return t.SHENGXIAO[e];
95
- return "";
96
- }
97
- getChongDesc() {
98
- return "(" + this.getChongGan() + this.getChong() + ")" + this.getChongShengXiao();
37
+ return e.SHENGXIAO[this._zhiIndex + 1];
99
38
  }
100
39
  getChongGan() {
101
- return t.CHONG_GAN[this._ganIndex];
40
+ return e.CHONG_GAN[this._ganIndex];
102
41
  }
103
42
  getChongGanTie() {
104
- return t.CHONG_GAN_TIE[this._ganIndex];
105
- }
106
- getYi() {
107
- return t.getTimeYi(
108
- this._lunar.getDayInGanZhiExact(),
109
- this.getGanZhi()
110
- );
111
- }
112
- getJi() {
113
- return t.getTimeJi(
114
- this._lunar.getDayInGanZhiExact(),
115
- this.getGanZhi()
116
- );
117
- }
118
- getXun() {
119
- return t.getXun(this.getGanZhi());
120
- }
121
- getXunKong() {
122
- return t.getXunKong(this.getGanZhi());
43
+ return e.CHONG_GAN_TIE[this._ganIndex];
123
44
  }
124
45
  getMinHm() {
125
- let n = this._lunar.getHour();
126
- return n < 1 ? "00:00" : n > 22 ? "23:00" : (n % 2 === 0 && (n -= 1), (n < 10 ? "0" : "") + n + ":00");
46
+ let t = this._lunar.getHour();
47
+ return t < 1 ? "00:00" : t > 22 ? "23:00" : (t % 2 === 0 && (t -= 1), (t < 10 ? "0" : "") + t + ":00");
127
48
  }
128
49
  getMaxHm() {
129
- let n = this._lunar.getHour();
130
- return n < 1 ? "00:59" : n > 22 ? "23:59" : (n % 2 !== 0 && (n += 1), (n < 10 ? "0" : "") + n + ":59");
50
+ let t = this._lunar.getHour();
51
+ return t < 1 ? "00:59" : t > 22 ? "23:59" : (t % 2 !== 0 && (t += 1), (t < 10 ? "0" : "") + t + ":59");
131
52
  }
132
53
  toString() {
133
54
  return this.getGanZhi();
134
55
  }
135
56
  }
136
57
  export {
137
- s as LunarTime
58
+ a as LunarTime
138
59
  };