Giter VIP home page Giter VIP logo

6tail / lunar-javascript Goto Github PK

View Code? Open in Web Editor NEW
817.0 18.0 175.0 319 KB

日历、公历(阳历)、农历(阴历、老黄历)、佛历、道历,支持节假日、星座、儒略日、干支、生肖、节气、节日、彭祖百忌、每日宜忌、吉神宜趋凶煞宜忌、吉神(喜神/福神/财神/阳贵神/阴贵神)方位、胎神方位、冲煞、纳音、星宿、八字、五行、十神、建除十二值星、青龙名堂等十二神、黄道黑道日及吉凶等。lunar is a calendar library for Solar and Chinese Lunar.

Home Page: https://6tail.cn/calendar/api.html

License: MIT License

HTML 0.13% JavaScript 99.87%
javascript calendar lunar

lunar-javascript's People

Contributors

6tail avatar helloxum avatar player626 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lunar-javascript's Issues

八字的月份计算错误

今天 2022 年5月5日
var lunar = Lunar.fromDate(new Date());
var d = lunar.getEightChar();

console.log(d);
输出:
壬寅 甲辰 戊午 丁巳

但是万年历,2022年5月5日是乙巳月

HolidayUtils 获取的 2024 年春节假期数据有误

问题:通过 HolidayUtil.getHolidays(2024, 2) 获取 2024 年 2 月的节假日,发现 2024-02-04 出现在了结果中,而这一天并非春节假日

image

期望:返回的春节假期中不包含 2024-02-04 这一天

getNextJie和getPrevJie如何正确使用?这应该是bug吧!

let s = Solar.fromYmd(2024, 2, 4); // 立春
let nx = s.getLunar().getNextJie(true); // ❌立春,✔惊蛰
let px = s.getLunar().getPrevJie(true); // ❌立春, ✔小寒
console.log(nx.getName(),px.getName());
这三个居然全部都是立春?卡bug吗 [苦笑]

建议加上农历的天数

建议加上农历的天数,
下面的接口为阳历的天数
SolarUtil.getDaysOfYear(2023);
希望加上农历天数,比如2023农历天数为384天

关于二十八星宿的建议

6tail你好:

关于lunar-javascript里的二十八星宿排列,使用的是地支+周的计算方式。
而其他部分农历程序使用的是印度佛教的27星宿排布方式。(印度佛教所使用二十七星宿,传自中土。但因为观测位置原因,舍弃了牛宿。)

理由1:印度佛教排列的27星宿方法是对的,但是不适用北京时间。因为我国北京地区观测月宫黄道,是可以观测到牛宿的。
理由2:地支+周之所以不对,是因为周在古代计时中,采用的是七曜排序,与现代的“基督教礼拜日”相差甚远,使用+周的做法不提倡,也没有逻辑依据。

根据我使用观星方式所获得的二十八值日,采用农历月表的排列方式,恢复成二十八星宿相对来说更加准确。

二十八星宿资料采用:https://zh.wikipedia.org/wiki/%E4%BA%8C%E5%8D%81%E5%85%AB%E5%AE%BF%E4%B8%AD%E8%A5%BF%E6%98%9F%E5%90%8D%E5%AF%B9%E7%85%A7%E8%A1%A8

根据对应现代星座名称,我观测了在不同阴历月日时,月亮所重叠的二十八星宿位置。

以此推荐您做以下修改:例如:

月排序
export const CN_MONTH = '十一_十二_正_二_三_四_五_六_七_八_九_十'.split('_')

二十八星宿排序:
export const XINGXIU28 = '角_亢_氐_房_心_尾_箕_斗_牛_女_虚_危_室_壁_奎_娄_胃_昴_毕_觜_参_井_鬼_柳_星_张_翼_轸'.split('')
export const XX28_WX = '木_金_土_日_月_火_水_木_金_土_日_月_火_水_木_金_土_日_月_火_水_木_金_土_日_月_火_水'.split('
')
export const XX28_MING = '蛟_龙_貉_兔_狐_虎_豹_獬_牛_蝠_鼠_燕_猪_貐_狼_狗_雉_鸡_乌_猴_猿_犴_羊_獐_马_鹿_蛇_蚓'.split('_')

二十八星宿对应月数组的起始排序:
var sort = '8_11_13_15_17_19_21_23_26_1_3_5'.split('_')

var R = {}
for (var i = 0; i < 12; i++) {
var f = sort[i] - 1
R[CN_MONTH[i]] = []
for (let j = 0; j < 30; j++) {
R[CN_MONTH[i]].push([XINGXIU28[(f + j) % 28], XX28_WX[(f + j) % 28], XX28_MING[(f + j) % 28]])
}
}
return R

由此可获得对于北京时间相对准确的二十八星宿值日列表,也符合现代观星所获得的二十八星宿值日结果。

请您参考,此致,敬礼。

2024-12-1房宿

节日数组数据为空

根据实例调试,节日的数组为空
var d = Solar.fromYmd(2023, 1, 1);
var l = d.getFestivals();
for (var i=0, j=l.length; i<j; i++){
console.log(l[i]);
}

使用Solar.fromBaZi无法反推出日期

Solar.fromBaZi('癸卯', '甲寅', '丙午', '子酉')
按照以上四柱八字返回的日期应该是:
1963-3-4 18:00
2023-2-17 18:00
但是根据lunar库获取的是空数组,麻烦作者看看哦

星宿有误

看起来确实星宿有误,阴历1995-3-28,找了4个网站都是[胃宿(胃土雉)],
1
2
3
4

线上API返回的是西方奎木狼
5

IE7以下报错,源代码有一处问题

fromYmdHms:function(lunarYear,lunarMonth,lunarDay,hour,minute,second){return _fromYmdHms(lunarYear,lunarMonth,lunarDay,hour,minute,second);},

此行末尾多了一个逗号,低版本的IE对JSON格式容错性低,会报错无法使用。改了之后能正常运行。
BTW,库还不错哦,加油~~

有一个小bug哦,然后还有一个期待

bug: 在使用中,请将1994年7月的大暑使用.toYmdHms()来输出,你会发现秒是60.这个玩意整死我了哦。

期待:排大运那里,默认是是个数组,包含了出生年,可以不可以指定排大运的数字,不会限制在10个loop里。比如12个大运年限。我知道这很无聊,可是的确需要。

1582年数据错误

1582年10月发生过特殊事件,导致中间少了10天,这里需要特别处理下.
1582年10月5日至 1582年10月14 日. 被从历法中抹去了.
具体的原因是因为以前没有逢百不润的说法(现在历法 1500 年是不润的,但是老的历法 1500 年是闰年的), 还请更新一下

getWeeksOfMonth获取错误

如题,如果week小于start时结果错误,可参考:
getWeeksOfMonth:function(year, month, start){
let week = Solar.fromYmd(year, month, 1).getWeek()
week = week < start ? week + 7 : week
return Math.ceil((this.getDaysOfMonth(year, month) + week - start)/7);
}

干支错误

2024-02-04 立春,应为 甲辰(龙)年

2024-02-04 00:00:00 闰年 星期日 水瓶座
二〇二三年腊月廿五 癸卯(兔)年 丙寅(虎)月 戊戌(狗)日 子(鼠)时 纳音[金箔金 炉中火 平地木 桑柘木] 星期日 [立春] 南方朱雀 星宿[星日马](凶) 彭祖百忌[戊不受田田主不祥 戌不吃犬作怪上床] 喜神方位[巽](东南) 阳贵神方位[艮](东北) 阴贵神方位[坤](西南) 福神方位[艮](东北) 财神方位[坎](正北) 冲[(壬辰)龙] 煞[北]

关于道历年的计算

首先,感谢开发者开发的这个日历工具库!我使用了本项目给自用的 html 时钟加入了农历。
今天(本 Issue 发布时)是 2024 年 6 月 6 日,甲辰年五月初一,目前道历实例会输出四七二一年五月初一
图片
最近在逛维基的时候发现,2024年在春节后在黄帝纪元(也就是道历年)是4722年:
图片
图片
图片
也就是春节前是公历+2697春节开始公历+2698
比如今天(本 Issue 发布时)是四七二二年五月初一而非四七二一年五月初一(顺便一提,道历的繁体字是道曆而不是道歷用于历法)。

为什么会少算一年?

目前主流算法(包括微鲤万年历、一些道教网站等)是“春节前是公历+2696春节开始公历+2697”,可能是按照了百度百科的介绍“黄帝纪元=西元+2697年”便以为是“春节开始公历+2697”——然而百度百科自己都“乱糟糟的”:
图片
这个是春节前是公历+2697春节开始公历+2698
图片
这个却是春节前是公历+2696春节开始公历+2697,这种算法一传十十传百,甚至连手机 APP “微鲤万年历(原名中华万年历)”都用了这个。
1717662687863

Vue3调用getYun()发生错误: Converting circular structure to JSON

Vue3调用getYun()发生错误:

shared.esm-bundler.js:448 Uncaught (in promise) TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property '_p' -> object with constructor 'Object'
| property 'eightChar' -> object with constructor 'Object'
| property '_p' -> object with constructor 'Object'
--- property 'lunar' closes the circle

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.