ChineseCalendar 1.0.4

dotnet add package ChineseCalendar --version 1.0.4
                    
NuGet\Install-Package ChineseCalendar -Version 1.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ChineseCalendar" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ChineseCalendar" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="ChineseCalendar" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ChineseCalendar --version 1.0.4
                    
#r "nuget: ChineseCalendar, 1.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ChineseCalendar@1.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ChineseCalendar&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=ChineseCalendar&version=1.0.4
                    
Install as a Cake Tool

ChineseCalendar

农历日期和公历农历节假日

ChineseDate 农历日期

var cdate = ChineseDate.From(DateTime.Today);
Console.WriteLine(cdate.ToString());
Console.WriteLine("日历名称:" + cdate.CalendarName);
Console.WriteLine("天干:" + cdate.CelestialStem);
Console.WriteLine("地支:" + cdate.TerrestrialBranch);
Console.WriteLine("干支:" + cdate.ChineseEra);
Console.WriteLine("生肖:" + cdate.AnimalSign);
Console.WriteLine("年份:" + cdate.YearString);
Console.WriteLine("月份:" + cdate.MonthString);
Console.WriteLine("月:" + cdate.Month);
Console.WriteLine("月序号:" + cdate.MonthIndex);
Console.WriteLine("当年总月份数:" + cdate.MonthsInYear);
Console.WriteLine("农历日:" + cdate.DayString);
Console.WriteLine("日:" + cdate.Day);
Console.WriteLine("当年总天数:" + cdate.DayInYear);
Console.WriteLine("当月总天数:" + cdate.DayInMonth);
Console.WriteLine("星期:" + cdate.DayOfWeek);
Console.WriteLine("当年第几天:" + cdate.DayOfYear);
Console.WriteLine("是否闰年:" + cdate.IsLeapMonth);
Console.WriteLine("当年的闰月份:" + cdate.LeapMonthOfYear);
庚子[鼠]年闰四月廿七
日历名称:农历
天干:庚
地支:子
干支:庚子
生肖:鼠
年份:二〇二〇
月份:闰四
月:4
月序号:5
当年总月份数:13
农历日:廿七
日:27
当年总天数:384
当月总天数:29
星期:Thursday
当年第几天:146
是否闰年:True
当年的闰月份:4
for(int i = 1; i <= 12; i++)
{
    var cdate = ChineseDate.From(2020, i, 1);
    Console.WriteLine(cdate.ToString());
    var cdate2 = ChineseDate.From(2020, i, -1);
    Console.WriteLine(cdate2.ToString());
}
for(int i = 1; i <= 13; i++)
{
    var cdate = ChineseDate.FromIndex(2020, i, 1);
    Console.WriteLine(cdate.ToString());
    var cdate2 = ChineseDate.FromIndex(2020, i, -1);
    Console.WriteLine(cdate2.ToString());
}
庚子[鼠]年正月初一
庚子[鼠]年正月廿九
庚子[鼠]年二月初一
庚子[鼠]年二月三十
庚子[鼠]年三月初一
庚子[鼠]年三月三十
庚子[鼠]年四月初一
庚子[鼠]年四月三十
庚子[鼠]年五月初一
庚子[鼠]年五月三十
庚子[鼠]年六月初一
庚子[鼠]年六月廿九
庚子[鼠]年七月初一
庚子[鼠]年七月廿九
庚子[鼠]年八月初一
庚子[鼠]年八月三十
庚子[鼠]年九月初一
庚子[鼠]年九月廿九
庚子[鼠]年十月初一
庚子[鼠]年十月三十
庚子[鼠]年冬月初一
庚子[鼠]年冬月廿九
庚子[鼠]年腊月初一
庚子[鼠]年腊月三十
庚子[鼠]年正月初一
庚子[鼠]年正月廿九
庚子[鼠]年二月初一
庚子[鼠]年二月三十
庚子[鼠]年三月初一
庚子[鼠]年三月三十
庚子[鼠]年四月初一
庚子[鼠]年四月三十
庚子[鼠]年闰四月初一
庚子[鼠]年闰四月廿九
庚子[鼠]年五月初一
庚子[鼠]年五月三十
庚子[鼠]年六月初一
庚子[鼠]年六月廿九
庚子[鼠]年七月初一
庚子[鼠]年七月廿九
庚子[鼠]年八月初一
庚子[鼠]年八月三十
庚子[鼠]年九月初一
庚子[鼠]年九月廿九
庚子[鼠]年十月初一
庚子[鼠]年十月三十
庚子[鼠]年冬月初一
庚子[鼠]年冬月廿九
庚子[鼠]年腊月初一
庚子[鼠]年腊月三十

Festival 节假日

Festival  节假日基类
  -- FixDateFestival	固定日期节假日
  -- LoopFestival		循环节假日
  	 -- GregorianFestival	公历节假日
  	 -- ChineseFestival		农历节假日
// 预定义节假日
 var festivals = new List<Festival>
 {
    ChineseFestival.SpringFestival,				// 春节
    ChineseFestival.LanternFestival,			//元宵节
    ChineseFestival.DragonHeadraisingDay,		//龙抬头
    ChineseFestival.DragonBoatFestival,			//端午
    ChineseFestival.QixiFestival,				//七夕
    ChineseFestival.GhostFestival,				//中元节
    ChineseFestival.MidAutumnFestival,			//中秋
    ChineseFestival.DoubleNinthFestival,		//重阳节
    ChineseFestival.NewYearsEve,				//除夕

    GregorianFestival.NewYearsDay,				//元旦
    GregorianFestival.ArborDay,					//植树节
    GregorianFestival.TheTombWeepingDay,		//清明节
    GregorianFestival.InternationalWorkersDay,	//劳动节
    GregorianFestival.TheNationalDay,			//国庆节
};
Assert.All<Festival>(festivals, item =>
{
    Output.WriteLine(item.Name + " -- " + item.Description);
    var last = item.GetLastDate(DateTime.Today, false);
    Output.WriteLine($"上一个{ item.Name} 在 {last:yyyy-MM-dd}");
    var next = item.GetNextDate(DateTime.Today, true);
    Output.WriteLine($"下一个{ item.Name} 在 {next:yyyy-MM-dd}");
});
春节 -- 正月初一
上一个春节 在 2020-01-25
下一个春节 在 2021-02-12
元宵节 -- 正月十五
上一个元宵节 在 2020-02-08
下一个元宵节 在 2021-02-26
龙抬头 -- 二月初二
上一个龙抬头 在 2020-02-24
下一个龙抬头 在 2021-03-14
端午 -- 五月初五
上一个端午 在 2019-06-07
下一个端午 在 2020-06-25
七夕 -- 七月初七
上一个七夕 在 2019-08-07
下一个七夕 在 2020-08-25
中元节 -- 七月十五
上一个中元节 在 2019-08-15
下一个中元节 在 2020-09-02
中秋 -- 八月十五
上一个中秋 在 2019-09-13
下一个中秋 在 2020-10-01
重阳节 -- 九月初九
上一个重阳节 在 2019-10-07
下一个重阳节 在 2020-10-25
除夕 -- 大年三十
上一个除夕 在 2020-01-24
下一个除夕 在 2021-02-11
元旦 -- 1月1日
上一个元旦 在 2020-01-01
下一个元旦 在 2021-01-01
植树节 -- 3月12日
上一个植树节 在 2020-03-12
下一个植树节 在 2021-03-12
清明 -- 4月5日
上一个清明 在 2020-04-05
下一个清明 在 2021-04-05
劳动节 -- 5月1日
上一个劳动节 在 2020-05-01
下一个劳动节 在 2021-05-01
国庆节 -- 10月1日
上一个国庆节 在 2019-10-01
下一个国庆节 在 2020-10-01
固定节假日
        public void TestFixFestival()
        {
            var fes = new FixDateFestival("大阅兵", 2015, 9, 3, "抗战暨反法西斯胜利70周年大阅兵");
            Output.WriteLine(fes.Name + " -- " + fes.Description);
            var last = fes.GetLastDate(DateTime.Today, false);
            Output.WriteLine($"上一个{ fes.Name} 在 {last:yyyy-MM-dd}");
            var next = fes.GetNextDate(DateTime.Today, true);
            Output.WriteLine($"下一个{ fes.Name} 在 {next:yyyy-MM-dd}");
        }
大阅兵 -- 抗战暨反法西斯胜利70周年大阅兵
上一个大阅兵 在 2015-09-03
下一个大阅兵 在
生日
        public void TestBirthday()
        {
            var fes = new GregorianFestival(name, month, day, year, "生日");
            Output.WriteLine($"{fes.Name} {fes.Description} :{fes.FirstYear}-{fes.Month}-{fes.Day}");
            var first = fes.First;
            var cfirst = ChineseDate.From(first.Value);
            var cfes = new ChineseFestival(name, cfirst.Month, cfirst.Day, cfirst.Year, "农历生日");
            Output.WriteLine($"{cfes.Name} {cfes.Description} :{cfes.FirstYear}-{cfes.Month}-{cfes.Day}");
            DateTime? date = first;
            DateTime? cdate = cfirst.ToDate();
            var index = 0;
            while(true)
            {
                try
                {
                    index++;
                    date = fes.GetNextDate(date, false);
                    cdate = cfes.GetNextDate(cdate, false);
                    var date2 = ChineseDate.From(date.Value);
                    var cdate2 = ChineseDate.From(cdate.Value);
                    if(index % 5 == 0)
                    {
                        Output.WriteLine($"{fes.Name} {index}岁{fes.Description}:{date:yyyy-MM-dd dddd} 农历{date2}");
                        Output.WriteLine($"{cfes.Name} {index}岁{cfes.Description}:{cdate:yyyy-MM-dd dddd} 农历{cdate2}");
                    }
                    if(!date.HasValue || index > 100)
                    {
                        break;
                    }
                }
                catch(Exception ex)
                {
                    Output.WriteLine("超出计算范围:" + ex.Message);
                    break;
                }
            }
        }
李五月 生日 :2017-5-12
李五月 农历生日 :2017-4-17
李五月 5岁生日:2022-05-12 星期四 农历壬寅[虎]年四月十二
李五月 5岁农历生日:2022-05-17 星期二 农历壬寅[虎]年四月十七
李五月 10岁生日:2027-05-12 星期三 农历丁未[羊]年四月初七
李五月 10岁农历生日:2027-05-22 星期六 农历丁未[羊]年四月十七
李五月 15岁生日:2032-05-12 星期三 农历壬子[鼠]年四月初四
李五月 15岁农历生日:2032-05-25 星期二 农历壬子[鼠]年四月十七
李五月 20岁生日:2037-05-12 星期二 农历丁巳[蛇]年三月廿七
李五月 20岁农历生日:2037-05-31 星期日 农历丁巳[蛇]年四月十七
李五月 25岁生日:2042-05-12 星期一 农历壬戌[狗]年三月廿三
李五月 25岁农历生日:2042-06-04 星期三 农历壬戌[狗]年四月十七
李五月 30岁生日:2047-05-12 星期日 农历丁卯[免]年四月十八
李五月 30岁农历生日:2047-05-11 星期六 农历丁卯[免]年四月十七
李五月 35岁生日:2052-05-12 星期日 农历壬申[猴]年四月十四
李五月 35岁农历生日:2052-05-15 星期三 农历壬申[猴]年四月十七
李五月 40岁生日:2057-05-12 星期六 农历丁丑[牛]年四月初九
李五月 40岁农历生日:2057-05-20 星期日 农历丁丑[牛]年四月十七
李五月 45岁生日:2062-05-12 星期五 农历壬午[马]年四月初四
李五月 45岁农历生日:2062-05-25 星期四 农历壬午[马]年四月十七
李五月 50岁生日:2067-05-12 星期四 农历丁亥[猪]年三月廿九
李五月 50岁农历生日:2067-05-29 星期日 农历丁亥[猪]年四月十七
李五月 55岁生日:2072-05-12 星期四 农历壬辰[龙]年三月廿五
李五月 55岁农历生日:2072-06-03 星期五 农历壬辰[龙]年四月十七
李五月 60岁生日:2077-05-12 星期三 农历丁酉[鸡]年四月二十
李五月 60岁农历生日:2077-05-09 星期日 农历丁酉[鸡]年四月十七
李五月 65岁生日:2082-05-12 星期二 农历壬寅[虎]年四月十五
李五月 65岁农历生日:2082-05-14 星期四 农历壬寅[虎]年四月十七
李五月 70岁生日:2087-05-12 星期一 农历丁未[羊]年四月初十
李五月 70岁农历生日:2087-05-19 星期一 农历丁未[羊]年四月十七
李五月 75岁生日:2092-05-12 星期一 农历壬子[鼠]年四月初七
李五月 75岁农历生日:2092-05-22 星期四 农历壬子[鼠]年四月十七
李五月 80岁生日:2097-05-12 星期日 农历丁巳[蛇]年四月初一
李五月 80岁农历生日:2097-05-28 星期二 农历丁巳[蛇]年四月十七
超出计算范围:日期超出范围 1901-02-19(公历) -- 2101-01-28(公历)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.0

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.4 765 2/6/2023
1.0.3 574 7/25/2022
1.0.2 533 6/15/2021
1.0.1 600 6/24/2020
1.0.0 551 6/18/2020