Lunar Solar Calendar Converter 是一个多语言支持的公历(阳历)和农历(阴历)转换工具。这个开源项目提供了一种简单而准确的方法来进行日期转换,支持1900年到2100年之间的日期。
根据您使用的编程语言,您可以通过以下方式获取并使用这个转换工具:
对于Python用户,可以通过pip安装:
pip install LunarSolarConverter
对于其他语言,您可以直接从GitHub仓库下载相应的源代码文件。
以下是在不同编程语言中使用这个转换工具的基本API:
C#/Java
Solar solarDate = LunarSolarConverter.LunarToSolar(lunarDate);
Lunar lunarDate = LunarSolarConverter.SolarToLunar(solarDate);
Objective-C
Solar *solarDate = [LunarSolarConverter lunarToSolar:lunarDate];
Lunar *lunarDate = [LunarSolarConverter solarToLunar:solarDate];
PHP
$solarDate = LunarSolarConverter::LunarToSolar($lunarDate);
$lunarDate = LunarSolarConverter::SolarToLunar($solarDate);
Python
solar_date = converter.LunarToSolar(lunar_date)
lunar_date = converter.SolarToLunar(solar_date)
JavaScript
let solarDate = converter.LunarToSolar(lunarDate);
let lunarDate = converter.SolarToLunar(solarDate);
C/C++
Solar solarDate = LunarToSolar(lunarDate);
Lunar lunarDate = SolarToLunar(solarDate);
Ruby
solar_date = lunar_to_solar(lunar_date)
lunar_date = solar_to_lunar(solar_date)
Swift
let solarDate = LunarSolarConverter.LunarToSolar(lunar: lunarDate)
let lunarDate = LunarSolarConverter.SolarToLunar(solar: solarDate)
Go
solarDate := LunarToSolar(lunarDate)
lunarDate := SolarToLunar(solarDate)
Dart
var solarDate = LunarSolarConverter.lunarToSolar(lunarDate);
var lunarDate = LunarSolarConverter.solarToLunar(solarDate);
项目提供了一个基于Node.js的HTTP服务器,用于验证不同语言实现的数据一致性:
node check.js
启动服务器。
http://localhost:1337/?src=2015,1,15
http://localhost:1337/?src=2014,11,25,0
Check.cs
文件实现了C#与Node.js的数据比对。
generate.htm
生成所需的数据。