Skip to content

Commit 1be77c3

Browse files
committed
阴历转阳历验收
1 parent 9783a61 commit 1be77c3

32 files changed

+13222
-0
lines changed

lxy_lunar_calender_library/README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# lxy_lunar_calender_library
2+
3+
**依赖库设计**
4+
5+
- 阴历转阳历:提供方法将阴历日期转换为阳历日期,即将阴历日期转换为公历日期。
6+
- 阳历转阴历:提供方法将阳历日期转换为阴历日期,即将公历日期转换为阴历日期。
7+
- 获取阴历月份信息:提供方法获取阴历月份的信息,例如阴历月的名称、大小月等。
8+
- 获取阴历节气信息:提供方法获取特定日期的阴历节气信息,例如立春、清明、夏至等。
9+
- 获取阴历年份的闰月信息:提供方法获取阴历年份的闰月信息,以及闰月的大小。
10+
- 获取阴历年份的生肖信息:提供方法获取特定年份对应的生肖信息。
11+
- 判断阴历日期是否为节日:提供方法判断特定阴历日期是否为传统节日,如春节、中秋节等。
12+
- 判断阳历日期是否为节日:提供方法判断特定阴历日期是否为传统节日,如春节、中秋节等。
13+
- 计算阴历日期间的天数差:提供方法计算两个阴历日期之间的天数差。
14+
15+
**主要特性**
16+
17+
- **逻辑一:** getJieQi 获取阴历节气信息
18+
- **逻辑二:** getLeapMonth 获取阴历年份的闰月信息
19+
- **逻辑三:** getLunar 通过阳历获取阴历
20+
- **逻辑四:** getLunarDiff 计算阴历日期间的天数差
21+
- **逻辑五:** getMonthInChinese 获取阴历月份信息
22+
- **逻辑六:** getSolar 通过阴历获取阳历
23+
- **逻辑七:** getYearShengXiao 获取生肖
24+
- **逻辑八:** isFestivals 阳历是否节日
25+
- **逻辑九:** isFestivalsByLunar 阴历是否节日
26+
27+
28+
29+
30+
31+
## 应用演示链接
32+
33+
[查看示例演示](示例演示链接)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><title></title><script src="https://unpkg.com/vue/dist/vue.js"></script><link href="/index.js" rel="preload" as="script"><script src="/index.js?c4b72f39876c172b9760"></script></head><body><div id="app"><u-button @click="show">Click me!</u-button></div><script>Vue.use(CloudUI);
2+
new Vue({
3+
el: '#app',
4+
methods: {
5+
show: function () {
6+
this.$alert('Hello World!');
7+
},
8+
},
9+
});</script></body></html>

lxy_lunar_calender_library/dist-theme/index.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lxy_lunar_calender_library/dist-theme/index.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lxy_lunar_calender_library/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import UtilsLogics from './logics';
2+
// COMPONENT IMPORTS
3+
export {
4+
UtilsLogics,
5+
// COMPONENT EXPORTS
6+
};
7+
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const {Solar,Lunar,LunarUtil,LunarYear} = require('lunar-javascript')
2+
import dayjs from "dayjs"
3+
4+
export default (dateData)=>{
5+
return Solar.fromDate(dayjs(dateData).toDate()).getLunar()
6+
}
7+
8+
export {
9+
Lunar,LunarUtil,LunarYear
10+
}
11+
12+
export function getNumberDate (dateStr){
13+
const date = dateStr.replace(/\S/g, match => {
14+
switch (match) {
15+
case '初': return '';
16+
case '零': return '0';
17+
case '正': return '1';
18+
case '一': return '1';
19+
case '二': return '2';
20+
case '三': return '3';
21+
case '四': return '4';
22+
case '五': return '5';
23+
case '六': return '6';
24+
case '七': return '7';
25+
case '八': return '8';
26+
case '九': return '9';
27+
case '十': return '1';
28+
case '廿': return '2';
29+
default :
30+
return ","
31+
}
32+
});
33+
return date
34+
}
35+
36+
// console.log(getNumberDate("一九八六年四月廿一"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: getJieQi
2+
description: 获取节气信息
3+
type: both
4+
belong: logic
5+
labels: [Runtime]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @param {string} dateData <false> 日期
3+
* @returns {string} result
4+
*/
5+
import init from "../../lib"
6+
export default (dateData)=>{
7+
return init(dateData).getJieQi()
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: getLeapMonth
2+
description: 获取闰月
3+
type: both
4+
belong: logic
5+
labels: [Runtime]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @param {string} dateData <false> 日期
3+
* @returns {string} result
4+
*/
5+
import init,{LunarYear} from "../../lib"
6+
export default (dateData)=>{
7+
return LunarYear.fromYear(init(dateData).getYear()).getLeapMonth()
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: getLunar
2+
description: 转阴历
3+
type: both
4+
belong: logic
5+
labels: [Runtime]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @param {string} dateData <false> 日期
3+
* @param {boolean} isFull <false> 是否完整
4+
* @returns {string} result
5+
*/
6+
import init from "../../lib"
7+
export default (dateData,isFull)=>{
8+
const lunar = init(dateData)
9+
return isFull ? lunar.toFullString() : lunar.toString()
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: getLunarDiff
2+
description: 获取阴历天数差
3+
type: both
4+
belong: logic
5+
labels: [Runtime]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @param {string} str1 <false> 阴历日期1
3+
* @param {string} str2 <false> 阴历日期2
4+
* @returns {string} result
5+
*/
6+
import {getNumberDate,Lunar} from "../../lib"
7+
import dayjs from "dayjs"
8+
export default (str1,str2,type="d")=>{
9+
const date1 = Lunar.fromYmd(...getNumberDate(str1).split(",")).getSolar()
10+
const date2 = Lunar.fromYmd(...getNumberDate(str2).split(",")).getSolar()
11+
return dayjs(date1).diff(dayjs(date2),type)
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: getMonthInChinese
2+
description: 转阴历月份
3+
type: both
4+
belong: logic
5+
labels: [Runtime]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @param {string} dateData <false> 日期
3+
* @returns {string} result
4+
*/
5+
import init from "../../lib"
6+
export default (dateData)=>{
7+
return init(dateData).getMonthInChinese()
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: getSolar
2+
description: 阴历转阳历
3+
type: both
4+
belong: logic
5+
labels: [Runtime]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @param {string} str <false> 阴历日期
3+
* @returns {string} result
4+
*/
5+
import init,{getNumberDate,Lunar} from "../../lib"
6+
export default (str)=>{
7+
const lunar = Lunar.fromYmd(...getNumberDate(str).split(",")).getSolar().toString()
8+
return lunar
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: getYearShengXiao
2+
description: 获取生肖
3+
type: both
4+
belong: logic
5+
labels: [Runtime]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @param {string} dateData <false> 日期
3+
* @returns {string} result
4+
*/
5+
import init from "../../lib"
6+
export default (dateData)=>{
7+
return init(dateData).getYearShengXiao()
8+
}
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const $libraryName = 'lxy_lunar_calender_library'
2+
3+
const UtilsLogics = {}
4+
import getLunar from './getLunar'
5+
import getSolar from './getSolar'
6+
import getMonthInChinese from './getMonthInChinese'
7+
import getJieQi from './getJieQi'
8+
import getLeapMonth from './getLeapMonth'
9+
import getYearShengXiao from './getYearShengXiao'
10+
import isFestivals from './isFestivals'
11+
import getLunarDiff from './getLunarDiff'
12+
import isFestivalsByLunar from './isFestivalsByLunar'
13+
// LOGIC IMPORTS
14+
15+
UtilsLogics.install = function (Vue, option = {}) {
16+
Vue.prototype.$library = Vue.prototype.$library || {}
17+
Vue.prototype.$library[`${$libraryName}`] = {}
18+
Vue.prototype.$library[`${$libraryName}`].getLunar=getLunar
19+
Vue.prototype.$library[`${$libraryName}`].getSolar=getSolar
20+
Vue.prototype.$library[`${$libraryName}`].getMonthInChinese=getMonthInChinese
21+
Vue.prototype.$library[`${$libraryName}`].getJieQi=getJieQi
22+
Vue.prototype.$library[`${$libraryName}`].getLeapMonth=getLeapMonth
23+
Vue.prototype.$library[`${$libraryName}`].getYearShengXiao=getYearShengXiao
24+
Vue.prototype.$library[`${$libraryName}`].isFestivals=isFestivals
25+
Vue.prototype.$library[`${$libraryName}`].getLunarDiff=getLunarDiff
26+
Vue.prototype.$library[`${$libraryName}`].isFestivalsByLunar=isFestivalsByLunar
27+
// LOGIC USE
28+
}
29+
30+
/* 阴转阳 */
31+
console.log(getSolar("一九八六年四月廿一")) // 1986-05-29
32+
/* 阳转阴 */
33+
console.log(getLunar("1998-10")); // 一九九八年八月十一
34+
/* 转阴历月份 */
35+
console.log(getMonthInChinese("1998-10")); // 八
36+
/* 获取阴历节气信息 */
37+
console.log(getJieQi("2024-2-4")); // 立春
38+
/* 获取闰月 */
39+
console.log(getLeapMonth("2024-2-4")); // 2
40+
/* 获取生肖 */
41+
console.log('获取生肖',getYearShengXiao("2024-2-4")); // 兔
42+
/* 获取节日 */
43+
console.log('是否节日',isFestivals("2024-2-12")); // 是
44+
/* 阴历是否节日 */
45+
console.log('阴历是否节日',isFestivalsByLunar("二零二四年正月初一")); // 是
46+
/* 获取阴历天数差 */
47+
console.log('天数差',getLunarDiff('一九八六年四月廿一','一九八六年四月廿九')); // 是
48+
49+
50+
export default UtilsLogics
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: isFestivals
2+
description: 获取节日
3+
type: both
4+
belong: logic
5+
labels: [Runtime]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @param {string} dateData <false> 日期
3+
* @returns {boolean} result
4+
*/
5+
import ww from "chinese-workday"
6+
export default (dateData)=>{
7+
const isHoliday = ww.isHoliday;
8+
return isHoliday(dateData)
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: isFestivalsByLunar
2+
description: 阴历是否节日
3+
type: both
4+
belong: logic
5+
labels: [Runtime]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @param {string} str <false> 阴历日期
3+
* @returns {boolean} result
4+
*/
5+
import {getNumberDate,Lunar} from "../../lib"
6+
import ww from "chinese-workday"
7+
export default (str)=>{
8+
const data = Lunar.fromYmd(...getNumberDate(str).split(",")).getSolar()
9+
const isHoliday = ww.isHoliday;
10+
return isHoliday(data)
11+
}
278 KB
Binary file not shown.

lxy_lunar_calender_library/manifest

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Plugin-Version: 1.0.0
2+
Library-Type: Frontend
3+
Metadata-File: usage.json
4+
packages/extension/[email protected]/dist-theme/demo.html: dist-theme/demo.html
5+
packages/extension/[email protected]/dist-theme/index.js: dist-theme/index.js
6+
packages/extension/[email protected]/dist-theme/index.js.map: dist-theme/index.js.map
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"name": "lxy_lunar_calender_library",
3+
"title": "阴历依赖库",
4+
"description": "",
5+
"version": "0.1.0",
6+
"main": "./index.js",
7+
"author": "",
8+
"repository": "",
9+
"homepage": "",
10+
"license": "MIT",
11+
"keywords": [
12+
"lcap",
13+
"material",
14+
"component"
15+
],
16+
"scripts": {
17+
"dev": "vue-cli-service doc --port 9090",
18+
"build:theme": "vue-cli-service library-build --dest dist-theme",
19+
"build:doc": "vue-cli-service doc-build",
20+
"build": "npm run build:theme",
21+
"usage": "lcap usage",
22+
"deploy": "lcap deploy dist-theme",
23+
"prepublishOnly": "lcap publish",
24+
"release": "lcap publish"
25+
},
26+
"vuePlugins": {},
27+
"babel": {},
28+
"vusion": {
29+
"ui": "cloud-ui.vusion"
30+
},
31+
"lcapVersion": "0.3.0",
32+
"devDependencies": {
33+
"@vue/cli-service": "^4.4.1",
34+
"cloud-ui.vusion": "^0.11.20",
35+
"core-js": "^3.6.5",
36+
"vue": "^2.6.12",
37+
"vue-cli-plugin-vusion": "0.14.2-beta",
38+
"vue-loader": "15.9.8"
39+
},
40+
"peerDependencies": {
41+
"cloud-ui.vusion": "^0.11.20",
42+
"vue": "^2.6.12"
43+
},
44+
"vetur": {
45+
"tags": "./vetur/tags.json",
46+
"attributes": "./vetur/attributes.json"
47+
},
48+
"template": {
49+
"inited": true
50+
},
51+
"dependencies": {
52+
"chinese-workday": "^1.10.0",
53+
"dayjs": "^1.11.10",
54+
"lunar-javascript": "^1.6.12"
55+
}
56+
}

0 commit comments

Comments
 (0)