npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

solarday2lunarday

v1.12.1

Published

将公历日期转为农历日期

Downloads

90

Readme

solar2lunar

使用可以将'YYYY-MM-DD'格式的字符串、时间戳,或者(year,month,day)

日期为参数,返回该日期的相关日期属性对象

举例:

solar2lunar('2025-05-01')

使用方法

import calendar from 'solarday2lunarday'

可调用方法

1、calendar.solar2lunar,

参数类型:

(1) 一个参数 :YYYY-MM-DD 格式的日期字符串

(2) 一个参数: YYYY/MM/DD 格式的日期字符串

(3) 一个参数:时间戳

(4) 三个参数: YYYY 格式年份, MM 格式月份, DD 格式日期 字符串或数字皆可

返回值类型

{

"lunarYear": 2025, // 表示阴历年份

"lunarYearCN": "二零二五", // 表示阴历年份的汉字

"lunarMonth": 4, // 表示阴历月份数字

"lunarMonthDays": 29, // 表示阴历当月有多少天

"fullLunarMonthString": "四月初四", // 阴历当天的全程

"zodiac": "蛇", // 表示生肖年

"IMonthCn": "四月", // 阴历月份的汉字

"IDayCn": "初四", // 表示阴历天的汉字

"solarYear": 2025, // 表示阳历年份数字

"solarYearCN": "二零二五", // 表示阳历年份汉字

"solarMonth": 5, // 表示阳历月份

"solarDay": 1, // 表示阳历日期

"solarMonthDays": 31, // 表示阳历当月有多少天

"gzYear": "乙巳", // 当年的干支年

"gzMonth": "辛巳", // 当月的干支月

"gzDay": "庚午", // 当天的干支日

"isToday": false, // 是否今天

"isLeapMonth": false, // 是否闰月

"isLeapYear": false, // 是否闰年

"ncWeek": "星期四", // 表示星期的汉字

"isTerm": true, // 是否节气

"Term": "立夏", // 节日名称

"constellation": "金牛座", // 星座名称

"GzNy": "覆灯火", // 干支纳音

"astroEn": "Taurus", // 星座英文名称

"isFestival": true, // 是否节日

"festivalName": "劳动节", // 节日中文名称

"festivalEnName": "International Labour Day", // 节日英文名称

"isLunarFestival": false // 是否农历节日

}

可调用方法

2、calendar.lunar2solar,

参数类型

(1) YYYY 格式年份数字 MM格式月份数字 DD格式日期数字 boolean格式是否闰月

返回值类型同上

可调用方法

3、calendar.isLeapYear

参数类型

(1) YYYY 格式年份数字

返回值 boolean 型, 表示该年份是否为闰年

可调用方法

4.calendar.getYearCN

参数类型

(1) YYYY 格式年份数字

返回值 汉字字符串 ,表示该年份的汉字 举例 1989 => 一九八九

可调用方法

4.calendar.lunarYearDays

获取返回农历某年一整年的总天数

参数类型

(1) YYYY 格式年份数字,指农历年

返回值 354, 355, 383, 384

可调用方法

5.calendar.getConstellation

根据输入的阳历月和阳历日获取星座

(1)参数类型 MM格式月份 DD格式日期

返回值类型:十二星座其中之一

6.calendar.getAllFestival

跟如输入的阳历年份,返回该年所有的节日

(1)参数类型 YYYY格式阳历年

返回值类型,节日数组

新增双节同庆的配置