初始化项目
[LunarCalendar.git] / README.html
CommitLineData
dbda9b49 1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3<head>
4<title>README</title>
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6<style type="text/css">
7/* GitHub stylesheet for MarkdownPad (http://markdownpad.com) */
8/* Author: Nicolas Hery - http://nicolashery.com */
9/* Version: b13fe65ca28d2e568c6ed5d7f06581183df8f2ff */
10/* Source: https://github.com/nicolahery/markdownpad-github */
11
12/* RESET
13=============================================================================*/
14
15html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
16 margin: 0;
17 padding: 0;
18 border: 0;
19}
20
21/* BODY
22=============================================================================*/
23
24body {
25 font-family: Helvetica, arial, freesans, clean, sans-serif;
26 font-size: 14px;
27 line-height: 1.6;
28 color: #333;
29 background-color: #fff;
30 padding: 20px;
31 max-width: 960px;
32 margin: 0 auto;
33}
34
35body>*:first-child {
36 margin-top: 0 !important;
37}
38
39body>*:last-child {
40 margin-bottom: 0 !important;
41}
42
43/* BLOCKS
44=============================================================================*/
45
46p, blockquote, ul, ol, dl, table, pre {
47 margin: 15px 0;
48}
49
50/* HEADERS
51=============================================================================*/
52
53h1, h2, h3, h4, h5, h6 {
54 margin: 20px 0 10px;
55 padding: 0;
56 font-weight: bold;
57 -webkit-font-smoothing: antialiased;
58}
59
60h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
61 font-size: inherit;
62}
63
64h1 {
65 font-size: 28px;
66 color: #000;
67}
68
69h2 {
70 font-size: 24px;
71 border-bottom: 1px solid #ccc;
72 color: #000;
73}
74
75h3 {
76 font-size: 18px;
77}
78
79h4 {
80 font-size: 16px;
81}
82
83h5 {
84 font-size: 14px;
85}
86
87h6 {
88 color: #777;
89 font-size: 14px;
90}
91
92body>h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child {
93 margin-top: 0;
94 padding-top: 0;
95}
96
97a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
98 margin-top: 0;
99 padding-top: 0;
100}
101
102h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
103 margin-top: 10px;
104}
105
106/* LINKS
107=============================================================================*/
108
109a {
110 color: #4183C4;
111 text-decoration: none;
112}
113
114a:hover {
115 text-decoration: underline;
116}
117
118/* LISTS
119=============================================================================*/
120
121ul, ol {
122 padding-left: 30px;
123}
124
125ul li > :first-child,
126ol li > :first-child,
127ul li ul:first-of-type,
128ol li ol:first-of-type,
129ul li ol:first-of-type,
130ol li ul:first-of-type {
131 margin-top: 0px;
132}
133
134ul ul, ul ol, ol ol, ol ul {
135 margin-bottom: 0;
136}
137
138dl {
139 padding: 0;
140}
141
142dl dt {
143 font-size: 14px;
144 font-weight: bold;
145 font-style: italic;
146 padding: 0;
147 margin: 15px 0 5px;
148}
149
150dl dt:first-child {
151 padding: 0;
152}
153
154dl dt>:first-child {
155 margin-top: 0px;
156}
157
158dl dt>:last-child {
159 margin-bottom: 0px;
160}
161
162dl dd {
163 margin: 0 0 15px;
164 padding: 0 15px;
165}
166
167dl dd>:first-child {
168 margin-top: 0px;
169}
170
171dl dd>:last-child {
172 margin-bottom: 0px;
173}
174
175/* CODE
176=============================================================================*/
177
178pre, code, tt {
179 font-size: 12px;
180 font-family: Consolas, "Liberation Mono", Courier, monospace;
181}
182
183code, tt {
184 margin: 0 0px;
185 padding: 0px 0px;
186 white-space: nowrap;
187 border: 1px solid #eaeaea;
188 background-color: #f8f8f8;
189 border-radius: 3px;
190}
191
192pre>code {
193 margin: 0;
194 padding: 0;
195 white-space: pre;
196 border: none;
197 background: transparent;
198}
199
200pre {
201 background-color: #f8f8f8;
202 border: 1px solid #ccc;
203 font-size: 13px;
204 line-height: 19px;
205 overflow: auto;
206 padding: 6px 10px;
207 border-radius: 3px;
208}
209
210pre code, pre tt {
211 background-color: transparent;
212 border: none;
213}
214
215kbd {
216 -moz-border-bottom-colors: none;
217 -moz-border-left-colors: none;
218 -moz-border-right-colors: none;
219 -moz-border-top-colors: none;
220 background-color: #DDDDDD;
221 background-image: linear-gradient(#F1F1F1, #DDDDDD);
222 background-repeat: repeat-x;
223 border-color: #DDDDDD #CCCCCC #CCCCCC #DDDDDD;
224 border-image: none;
225 border-radius: 2px 2px 2px 2px;
226 border-style: solid;
227 border-width: 1px;
228 font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
229 line-height: 10px;
230 padding: 1px 4px;
231}
232
233/* QUOTES
234=============================================================================*/
235
236blockquote {
237 border-left: 4px solid #DDD;
238 padding: 0 15px;
239 color: #777;
240}
241
242blockquote>:first-child {
243 margin-top: 0px;
244}
245
246blockquote>:last-child {
247 margin-bottom: 0px;
248}
249
250/* HORIZONTAL RULES
251=============================================================================*/
252
253hr {
254 clear: both;
255 margin: 15px 0;
256 height: 0px;
257 overflow: hidden;
258 border: none;
259 background: transparent;
260 border-bottom: 4px solid #ddd;
261 padding: 0;
262}
263
264/* TABLES
265=============================================================================*/
266
267table th {
268 font-weight: bold;
269}
270
271table th, table td {
272 border: 1px solid #ccc;
273 padding: 6px 13px;
274}
275
276table tr {
277 border-top: 1px solid #ccc;
278 background-color: #fff;
279}
280
281table tr:nth-child(2n) {
282 background-color: #f8f8f8;
283}
284
285/* IMAGES
286=============================================================================*/
287
288img {
289 max-width: 100%
290}
291</style>
292</head>
293<body>
294<h1>LunarCalendar</h1>
295<p>农历(阴历)万年历,是一款支持Node.js和浏览器端使用的全功能农历和公历日历类库。支持农历与公历之间相互转换,含有二十四节气,天干地支纪年纪月纪日,生肖属相,公历节假日及农历传统节假日信息等功能。自带2013-2014节假日安排数据,并可自行配置。带有黄历数据,可自行选择配置。支持1891-2100年。使用<strong>LunarCalendar</strong>可快速开发一款属于自己的万年历产品,行动起来吧!</p>
296<h2>Install</h2>
297<ol>
298<li>Node.js服务器端(使用npm安装):
299<code>npm install lunar-calendar</code></li>
300<li>浏览器端使用,引用脚本:
301<code>&lt;script type=&quot;text/javascript&quot; src=&quot;lib/LunarCalendar.js&quot;&gt;&lt;/script&gt;</code></li>
302</ol>
303<h2>Usage</h2>
304<h3>Node.js</h3>
305<p>var LunarCalendar = require(&quot;lunar-calendar&quot;);</p>
306<h3>浏览器</h3>
307<p><code>window.LunarCalendar</code>是一个全局对象,可以全局作用域直接调用。</p>
308<h2>方法列表</h2>
309<h3>LunarCalendar.calendar(year,month[,fill])</h3>
310<p>通过公历获取某月农历数据</p>
311<h4>参数说明</h4>
312<ul>
313<li>@param {Number} <code>year</code> 公历年 范围[1891-2100]</li>
314<li>@param {Number} <code>month</code> 公历月 范围[1-12]</li>
315<li>@param {Boolean} <code>fill</code>(可选) 是否填充当月日历首尾日期,设为true时,会在首尾填入上下月数据,自动补全一个7*6阵列数据。(可更美观的打造你的万年历产品)</li>
316</ul>
317<h4>返回数据</h4>
318<pre><code>{
319 &quot;firstDay&quot;: 5, //该月1号星期几(日历开始位置)
320 &quot;monthDays&quot;: 28, //该月天数
321 &quot;monthData&quot;: [ //本月所有日历数据
322 {
323 &quot;year&quot;: 2014, //公历年
324 &quot;month&quot;: 2, //公历月
325 &quot;day&quot;: 1, //公历日
326 &quot;zodiac&quot;: &quot;蛇&quot;, //生肖属相
327 &quot;GanZhiYear&quot;: &quot;癸巳&quot;, //干支纪年
328 &quot;GanZhiMonth&quot;: &quot;乙丑&quot;, //干支纪月
329 &quot;GanZhiDay&quot;: &quot;癸卯&quot;, //干支纪日
330 &quot;worktime&quot;: 2, //0无特殊安排,1工作,2放假
331 &quot;lunarYear&quot;: 2014, //农历年
332 &quot;lunarMonth&quot;: 1, //农历月(1-13,有闰月情况,比如当前闰9月,10表示闰9月,11表示10月)
333 &quot;lunarDay&quot;: 2, //农历日
334 &quot;lunarMonthName&quot;: &quot;正月&quot;, //农历月中文名
335 &quot;lunarDayName&quot;: &quot;初二&quot;, //农历日中文名
336 &quot;lunarLeapMonth&quot;: 9, //农历闰月所在月份,0表示无闰月
337 &quot;solarFestival&quot;: &quot;&quot;, //公历节假日,undefined或‘劳动节’之类
338 &quot;lunarFestival&quot;: &quot;&quot;, //农历节假日,undefined或‘除夕’之类
339 &quot;term&quot;: &quot;&quot; //二十四节气名,undefined或‘立春’之类
340 },
341 ...
342 ]
343}
344</code></pre>
345
346<h3>LunarCalendar.solarCalendar(year,month[,fill])</h3>
347<p>获取公历某月日历数据(不带农历信息)</p>
348<h4>参数说明</h4>
349<ul>
350<li>@param {Number} <code>year</code> 公历年 范围[1-~]公元后</li>
351<li>@param {Number} <code>month</code> 公历月 范围[1-12]</li>
352<li>@param {Boolean} <code>fill</code>(可选) 是否填充当月日历首尾日期,设为true时,会在首尾填入上下月数据,自动补全一个7*6阵列数据。(可更美观的打造你的万年历产品)</li>
353</ul>
354<h4>返回数据</h4>
355<pre><code>{
356 &quot;firstDay&quot;: 5, //该月1号星期几(日历开始位置)
357 &quot;monthDays&quot;: 28, //该月天数
358 &quot;monthData&quot;: [ //本月所有日历数据
359 {
360 &quot;year&quot;: 2014, //公历年
361 &quot;month&quot;: 2, //公历月
362 &quot;day&quot;: 1 //公历日
363 },
364 ...
365 ]
366}
367</code></pre>
368
369<h3>LunarCalendar.solarToLunar(year,month,day)</h3>
370<p>将公历转换为农历</p>
371<h4>参数说明</h4>
372<ul>
373<li>@param {Number} <code>year</code> 公历年 范围[1891-2100]</li>
374<li>@param {Number} <code>month</code> 公历月 范围[1-12]</li>
375<li>@param {Number} <code>day</code> 公历日 范围[1-31]</li>
376</ul>
377<h4>返回数据</h4>
378<pre><code>{
379 &quot;zodiac&quot;: &quot;蛇&quot;, //生肖属相
380 &quot;GanZhiYear&quot;: &quot;癸巳&quot;, //干支纪年
381 &quot;GanZhiMonth&quot;: &quot;乙丑&quot;, //干支纪月
382 &quot;GanZhiDay&quot;: &quot;癸卯&quot;, //干支纪日
383 &quot;worktime&quot;: 2, //0无特殊安排,1工作,2放假
384 &quot;lunarYear&quot;: 2014, //农历年
385 &quot;lunarMonth&quot;: 1, //农历月(1-13,有闰月情况,比如当前闰9月,10表示闰9月,11表示10月)
386 &quot;lunarDay&quot;: 2, //农历日
387 &quot;lunarMonthName&quot;: &quot;正月&quot;, //农历月中文名
388 &quot;lunarDayName&quot;: &quot;初二&quot;, //农历日中文名
389 &quot;lunarLeapMonth&quot;: 9, //农历闰月所在月份,0表示无闰月
390 &quot;solarFestival&quot;: &quot;&quot;, //公历节假日,undefined或‘劳动节’之类
391 &quot;lunarFestival&quot;: &quot;&quot;, //农历节假日,undefined或‘除夕’之类
392 &quot;term&quot;: &quot;&quot; //二十四节气名,undefined或‘立春’之类
393}
394</code></pre>
395
396<h3>LunarCalendar.lunarToSolar(year,month,day)</h3>
397<p>将农历转换为公历</p>
398<h4>参数说明</h4>
399<ul>
400<li>@param {Number} <code>year</code> 农历年 范围[1891-2100]</li>
401<li>@param {Number} <code>month</code> 农历月 范围[1-13](有闰月情况,比如当前闰9月,10表示闰9月,11表示10月)</li>
402<li>@param {Number} <code>day</code> 农历日 范围[1-30]</li>
403</ul>
404<h4>返回数据</h4>
405<pre><code>{
406 &quot;year&quot;: 2014, //公历年
407 &quot;month&quot;: 1, //公历月
408 &quot;day&quot;: 31 //公历日
409}
410</code></pre>
411
412<h3>LunarCalendar.setWorktime(data)</h3>
413<p>设置某年的节假日安排信息(类库已内置2013-2014年的数据)</p>
414<h4>参数说明</h4>
415<ul>
416<li>@param {Object} <code>data</code> 节假日安排信息(以年为key,可设置多年)</li>
417<li>0:无特殊安排,1:工作,2:放假</li>
418</ul>
419<p><strong>参数data格式如下:</strong></p>
420<pre><code>{
421 &quot;y2014&quot;: {
422 &quot;d0101&quot;: 2,
423 &quot;d0126&quot;: 1,
424 &quot;d0131&quot;: 2,
425 &quot;d0201&quot;: 2,
426 &quot;d0202&quot;: 2,
427 &quot;d0203&quot;: 2,
428 &quot;d0204&quot;: 2,
429 &quot;d0205&quot;: 2,
430 &quot;d0206&quot;: 2,
431 &quot;d0208&quot;: 1,
432 &quot;d0405&quot;: 2,
433 &quot;d0407&quot;: 2,
434 &quot;d0501&quot;: 2,
435 &quot;d0502&quot;: 2,
436 &quot;d0503&quot;: 2,
437 &quot;d0504&quot;: 1,
438 &quot;d0602&quot;: 2,
439 &quot;d0908&quot;: 2,
440 &quot;d0928&quot;: 1,
441 &quot;d1001&quot;: 2,
442 &quot;d1002&quot;: 2,
443 &quot;d1003&quot;: 2,
444 &quot;d1004&quot;: 2,
445 &quot;d1005&quot;: 2,
446 &quot;d1006&quot;: 2,
447 &quot;d1007&quot;: 2,
448 &quot;d1011&quot;: 1
449 }
450}
451</code></pre>
452
453<h2>黄历数据</h2>
454<p>在目录/hl/下有2008-2020年的黄历数据,用户可自行选择在自己万年历中进行添加。</p>
455<h2>其它</h2>
456<ul>
457<li>项目主页:<a href="http://www.tuijs.com/" title="项目主页">http://www.tuijs.com/</a></li>
458<li>作者博客:<a href="http://www.2fz1.com/" title="作者博客">http://www.2fz1.com/</a></li>
459</ul>
460<p>JasonZhou</p>
461
462</body>
463</html>
464<!-- This document was created with MarkdownPad, the Markdown editor for Windows (http://markdownpad.com) -->