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 | |
15 | html, 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 | |
24 | body { |
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 | |
35 | body>*:first-child { |
36 | margin-top: 0 !important; |
37 | } |
38 | |
39 | body>*:last-child { |
40 | margin-bottom: 0 !important; |
41 | } |
42 | |
43 | /* BLOCKS |
44 | =============================================================================*/ |
45 | |
46 | p, blockquote, ul, ol, dl, table, pre { |
47 | margin: 15px 0; |
48 | } |
49 | |
50 | /* HEADERS |
51 | =============================================================================*/ |
52 | |
53 | h1, h2, h3, h4, h5, h6 { |
54 | margin: 20px 0 10px; |
55 | padding: 0; |
56 | font-weight: bold; |
57 | -webkit-font-smoothing: antialiased; |
58 | } |
59 | |
60 | h1 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 | |
64 | h1 { |
65 | font-size: 28px; |
66 | color: #000; |
67 | } |
68 | |
69 | h2 { |
70 | font-size: 24px; |
71 | border-bottom: 1px solid #ccc; |
72 | color: #000; |
73 | } |
74 | |
75 | h3 { |
76 | font-size: 18px; |
77 | } |
78 | |
79 | h4 { |
80 | font-size: 16px; |
81 | } |
82 | |
83 | h5 { |
84 | font-size: 14px; |
85 | } |
86 | |
87 | h6 { |
88 | color: #777; |
89 | font-size: 14px; |
90 | } |
91 | |
92 | body>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 | |
97 | a: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 | |
102 | h1+p, h2+p, h3+p, h4+p, h5+p, h6+p { |
103 | margin-top: 10px; |
104 | } |
105 | |
106 | /* LINKS |
107 | =============================================================================*/ |
108 | |
109 | a { |
110 | color: #4183C4; |
111 | text-decoration: none; |
112 | } |
113 | |
114 | a:hover { |
115 | text-decoration: underline; |
116 | } |
117 | |
118 | /* LISTS |
119 | =============================================================================*/ |
120 | |
121 | ul, ol { |
122 | padding-left: 30px; |
123 | } |
124 | |
125 | ul li > :first-child, |
126 | ol li > :first-child, |
127 | ul li ul:first-of-type, |
128 | ol li ol:first-of-type, |
129 | ul li ol:first-of-type, |
130 | ol li ul:first-of-type { |
131 | margin-top: 0px; |
132 | } |
133 | |
134 | ul ul, ul ol, ol ol, ol ul { |
135 | margin-bottom: 0; |
136 | } |
137 | |
138 | dl { |
139 | padding: 0; |
140 | } |
141 | |
142 | dl dt { |
143 | font-size: 14px; |
144 | font-weight: bold; |
145 | font-style: italic; |
146 | padding: 0; |
147 | margin: 15px 0 5px; |
148 | } |
149 | |
150 | dl dt:first-child { |
151 | padding: 0; |
152 | } |
153 | |
154 | dl dt>:first-child { |
155 | margin-top: 0px; |
156 | } |
157 | |
158 | dl dt>:last-child { |
159 | margin-bottom: 0px; |
160 | } |
161 | |
162 | dl dd { |
163 | margin: 0 0 15px; |
164 | padding: 0 15px; |
165 | } |
166 | |
167 | dl dd>:first-child { |
168 | margin-top: 0px; |
169 | } |
170 | |
171 | dl dd>:last-child { |
172 | margin-bottom: 0px; |
173 | } |
174 | |
175 | /* CODE |
176 | =============================================================================*/ |
177 | |
178 | pre, code, tt { |
179 | font-size: 12px; |
180 | font-family: Consolas, "Liberation Mono", Courier, monospace; |
181 | } |
182 | |
183 | code, 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 | |
192 | pre>code { |
193 | margin: 0; |
194 | padding: 0; |
195 | white-space: pre; |
196 | border: none; |
197 | background: transparent; |
198 | } |
199 | |
200 | pre { |
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 | |
210 | pre code, pre tt { |
211 | background-color: transparent; |
212 | border: none; |
213 | } |
214 | |
215 | kbd { |
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 | |
236 | blockquote { |
237 | border-left: 4px solid #DDD; |
238 | padding: 0 15px; |
239 | color: #777; |
240 | } |
241 | |
242 | blockquote>:first-child { |
243 | margin-top: 0px; |
244 | } |
245 | |
246 | blockquote>:last-child { |
247 | margin-bottom: 0px; |
248 | } |
249 | |
250 | /* HORIZONTAL RULES |
251 | =============================================================================*/ |
252 | |
253 | hr { |
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 | |
267 | table th { |
268 | font-weight: bold; |
269 | } |
270 | |
271 | table th, table td { |
272 | border: 1px solid #ccc; |
273 | padding: 6px 13px; |
274 | } |
275 | |
276 | table tr { |
277 | border-top: 1px solid #ccc; |
278 | background-color: #fff; |
279 | } |
280 | |
281 | table tr:nth-child(2n) { |
282 | background-color: #f8f8f8; |
283 | } |
284 | |
285 | /* IMAGES |
286 | =============================================================================*/ |
287 | |
288 | img { |
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><script type="text/javascript" src="lib/LunarCalendar.js"></script></code></li> |
302 | </ol> |
303 | <h2>Usage</h2> |
304 | <h3>Node.js</h3> |
305 | <p>var LunarCalendar = require("lunar-calendar");</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 | "firstDay": 5, //该月1号星期几(日历开始位置) |
320 | "monthDays": 28, //该月天数 |
321 | "monthData": [ //本月所有日历数据 |
322 | { |
323 | "year": 2014, //公历年 |
324 | "month": 2, //公历月 |
325 | "day": 1, //公历日 |
326 | "zodiac": "蛇", //生肖属相 |
327 | "GanZhiYear": "癸巳", //干支纪年 |
328 | "GanZhiMonth": "乙丑", //干支纪月 |
329 | "GanZhiDay": "癸卯", //干支纪日 |
330 | "worktime": 2, //0无特殊安排,1工作,2放假 |
331 | "lunarYear": 2014, //农历年 |
332 | "lunarMonth": 1, //农历月(1-13,有闰月情况,比如当前闰9月,10表示闰9月,11表示10月) |
333 | "lunarDay": 2, //农历日 |
334 | "lunarMonthName": "正月", //农历月中文名 |
335 | "lunarDayName": "初二", //农历日中文名 |
336 | "lunarLeapMonth": 9, //农历闰月所在月份,0表示无闰月 |
337 | "solarFestival": "", //公历节假日,undefined或‘劳动节’之类 |
338 | "lunarFestival": "", //农历节假日,undefined或‘除夕’之类 |
339 | "term": "" //二十四节气名,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 | "firstDay": 5, //该月1号星期几(日历开始位置) |
357 | "monthDays": 28, //该月天数 |
358 | "monthData": [ //本月所有日历数据 |
359 | { |
360 | "year": 2014, //公历年 |
361 | "month": 2, //公历月 |
362 | "day": 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 | "zodiac": "蛇", //生肖属相 |
380 | "GanZhiYear": "癸巳", //干支纪年 |
381 | "GanZhiMonth": "乙丑", //干支纪月 |
382 | "GanZhiDay": "癸卯", //干支纪日 |
383 | "worktime": 2, //0无特殊安排,1工作,2放假 |
384 | "lunarYear": 2014, //农历年 |
385 | "lunarMonth": 1, //农历月(1-13,有闰月情况,比如当前闰9月,10表示闰9月,11表示10月) |
386 | "lunarDay": 2, //农历日 |
387 | "lunarMonthName": "正月", //农历月中文名 |
388 | "lunarDayName": "初二", //农历日中文名 |
389 | "lunarLeapMonth": 9, //农历闰月所在月份,0表示无闰月 |
390 | "solarFestival": "", //公历节假日,undefined或‘劳动节’之类 |
391 | "lunarFestival": "", //农历节假日,undefined或‘除夕’之类 |
392 | "term": "" //二十四节气名,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 | "year": 2014, //公历年 |
407 | "month": 1, //公历月 |
408 | "day": 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 | "y2014": { |
422 | "d0101": 2, |
423 | "d0126": 1, |
424 | "d0131": 2, |
425 | "d0201": 2, |
426 | "d0202": 2, |
427 | "d0203": 2, |
428 | "d0204": 2, |
429 | "d0205": 2, |
430 | "d0206": 2, |
431 | "d0208": 1, |
432 | "d0405": 2, |
433 | "d0407": 2, |
434 | "d0501": 2, |
435 | "d0502": 2, |
436 | "d0503": 2, |
437 | "d0504": 1, |
438 | "d0602": 2, |
439 | "d0908": 2, |
440 | "d0928": 1, |
441 | "d1001": 2, |
442 | "d1002": 2, |
443 | "d1003": 2, |
444 | "d1004": 2, |
445 | "d1005": 2, |
446 | "d1006": 2, |
447 | "d1007": 2, |
448 | "d1011": 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) --> |