C#(ASP.NET)实现公历转农历的另一个方法

 

Dot Net 平台,对全球化的支持做的非常好,不得不称赞一个

通常,将公历转为农历,是个非常烦的事情,需要整理闰年、闰月等的对照表。

在.Net平台上,有了国际化的支持,这些东西,都已经提供了 ,我们需要做的,只是利用一下而已。

话不多说,直接上代码:

 

	/// <summary>
/// 公历转为农历的函数
/// </summary>
/// <remarks>作者:三角猫 DeltaCat</remarks>
/// <example>网址:http://www.zu14.cn</example>
/// <param name="solarDateTime">公历日期</param>
/// <returns>农历的日期</returns>
static string SolarToChineseLunisolarDate(DateTime solarDateTime)
{
    System.Globalization.ChineseLunisolarCalendar cal = new System.Globalization.ChineseLunisolarCalendar();

    int year = cal.GetYear(solarDateTime);
    int month = cal.GetMonth(solarDateTime);
    int day = cal.GetDayOfMonth(solarDateTime);
    
            
上一篇: JavaScript使用DocumentFragment加快DOM渲染速度
下一篇: 反编译Android APK文件详解【有图有真相】

1 条评论

  • Winter
    Winter 2011 年 8 月 12 日 05:06

    Wow, that's a raelly clever way of thinking about it!

发表评论

点击刷新