3 Star 4 Fork 7

刘泽文 / 阴阳历转换

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Lunar Solar Calendar Converter

公历(阳历) 农历(阴历)转换,支持时间段从1900-2100
如果需要更长的时间段,利用generate.htm生成的数据即可。
支持各种编程语言 C#,java,Objective-C,php,Python,javascript(nodejs),C/C++,ruby,swift,golang等
支持Mac,Windows,Android,WP多种平台

数据验证

1.用io.js(nodejs)写了一个httpserver,各种语言可以通过下面的http接口验证不同实现的数据一致性。
在javascript目录下node check.js启动

2.http://localhost:1337/?src=2015,1,15 (公历转农历,返回2014,11,25,0) 或者 
  http://localhost:1337/?src=2014,11,25,0 (农历转公历,返回2015,1,15)

3.比如在C#版本中,Check.cs 实现了C#与nodejs的数据比对

基本原理

  • 查表。有2个数据表,对于每一年,一张表存着X年正月初一对应的公历年月日,另一张表存着X年农历每个月的天数以及闰月的月份。 然后根据这两张表进行日期的偏移。
  • 原始数据通过了微软ChineseLunisolarCalendar类的比对。比对程序在C#版本中。
  • Swift由于苹果官方有NSCalendarIdentifierChinese,因此有跟Swift官方匹配的generate.swift。实际比对的结果,微软与苹果的数据有部分不一致。比如Apple 2057/9/28->2057年九月〇明显有问题。

API For CSharp or Java

/**
*农历转公历
*/
public static Solar LunarToSolar(Lunar lunar)

/**
*公历转农历
*/
public static Lunar SolarToLunar(Solar solar)

API For Objective-C

/**
*农历转公历
*/
+ (Solar *)lunarToSolar:(Lunar *)lunar;

/**
*公历转农历
*/
+ (Lunar *)solarToLunar:(Solar *)solar;

API For php

/**
*农历转公历
*/
public static function LunarToSolar($lunar)

/**
*公历转农历
*/
public static function SolarToLunar($solar)

API For python

//support pypi "pip install LunarSolarConverter"
//refer pypiDemo
/**
*农历转公历
*/
def LunarToSolar(self, lunar):

/**
*公历转农历
*/
def SolarToLunar(self, solar):

API For javascript

/**
*农历转公历
*/
this.LunarToSolar = function (lunar)

/**
*公历转农历
*/
this.SolarToLunar = function (solar)

API For C/C++

/**
*农历转公历
*/
Solar LunarToSolar(Lunar lunar);

/**
*公历转农历
*/
Lunar SolarToLunar(Solar solar);

API For ruby

/**
*农历转公历
*/
def lunar_to_solar(lunar)

/**
*公历转农历
*/
def solar_to_lunar(solar)

API For swift

/**
*农历转公历
*/
class func LunarToSolar( lunar:Lunar)->Solar

/**
*公历转农历
*/
class func SolarToLunar( solar:Solar)->Lunar

API For Go

/**
*农历转公历
*/
func  LunarToSolar(lunar Lunar) *Solar

/**
*公历转农历
*/
func SolarToLunar(solar Solar) *Lunar

API For Dart

/**
*农历转公历
*/
static lunarToSolar(Lunar lunar) 

/**
*公历转农历
*/
static solarToLunar(Solar solar)
MIT License Copyright (c) 2020 isee15 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

一个开源的农历阴历转换程序,各种编程语言! 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/liuzewen/Lunar-Solar-Calendar-Converter.git
git@gitee.com:liuzewen/Lunar-Solar-Calendar-Converter.git
liuzewen
Lunar-Solar-Calendar-Converter
阴阳历转换
master

搜索帮助

14c37bed 8189591 565d56ea 8189591