ChineseLunisolarCalendarYjFwkExtensions 1.2.1

Suggested Alternatives

YiJingFramework.Nongli

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package ChineseLunisolarCalendarYjFwkExtensions --version 1.2.1                
NuGet\Install-Package ChineseLunisolarCalendarYjFwkExtensions -Version 1.2.1                
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="ChineseLunisolarCalendarYjFwkExtensions" Version="1.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ChineseLunisolarCalendarYjFwkExtensions --version 1.2.1                
#r "nuget: ChineseLunisolarCalendarYjFwkExtensions, 1.2.1"                
#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.
// Install ChineseLunisolarCalendarYjFwkExtensions as a Cake Addin
#addin nuget:?package=ChineseLunisolarCalendarYjFwkExtensions&version=1.2.1

// Install ChineseLunisolarCalendarYjFwkExtensions as a Cake Tool
#tool nuget:?package=ChineseLunisolarCalendarYjFwkExtensions&version=1.2.1                

ChineseLunisolarCalendarYjFwkExtensions

ChineseLunisolarCalendarYjFwkExtensions 为 System.Globalization.ChineseLunisolarCalendar 提供了一些扩展方法。这里暂时拿测试项目的代码作为示例:

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Globalization;
using YiJingFramework.PrimitiveTypes;

namespace ChineseLunisolarCalendarYjFwkExtensions.Extensions.Tests;

[TestClass()]
public class ChineseLunisolarCalendarExtensionsTests
{
    #region 年干支和时辰地支
    [TestMethod()]
    public void GetYearGanzhiTest()
    {
        var calendar = new ChineseLunisolarCalendar();
        var dateTime = new DateTime(2023, 8, 16, 12, 41, 23);

        var (gan, zhi) = calendar.GetYearGanzhi(dateTime);
        Assert.AreEqual(Tiangan.Gui, gan);
        Assert.AreEqual(Dizhi.Mao, zhi);
    }

    [TestMethod()]
    public void GetShichenDizhiTest()
    {
        var calendar = new ChineseLunisolarCalendar();
        var dateTime = new DateTime(2023, 8, 16, 12, 41, 23);

        var shichen = calendar.GetShichenDizhi(dateTime);
        Assert.AreEqual(Dizhi.Wu, shichen);
    }
    #endregion

    #region 更好的月份信息
    [TestMethod()]
    public void GetMonthWithLeapTest()
    {
        var calendar = new ChineseLunisolarCalendar();

        var dateTime = new DateTime(2023, 8, 16, 12, 41, 23);
        Assert.AreEqual(8, calendar.GetMonth(dateTime));
        var (month, leap) = calendar.GetMonthWithLeap(dateTime);
        Assert.AreEqual(7, month);
        Assert.AreEqual(false, leap);

        dateTime = new DateTime(2023, 4, 19, 12, 41, 23);
        (month, leap) = calendar.GetMonthWithLeap(dateTime);
        Assert.AreEqual(2, month);
        Assert.AreEqual(true, leap);
    }
    #endregion

    #region 年月日的中文表示
    [TestMethod()]
    public void GetYearGanzhiInChineseTest()
    {
        var calendar = new ChineseLunisolarCalendar();
        var dateTime = new DateTime(2023, 8, 16, 12, 41, 23);

        var year = calendar.GetYearGanzhiInChinese(dateTime);
        Assert.AreEqual("癸卯", year);
    }

    [TestMethod()]
    public void GetYearInChineseTest()
    {
        var calendar = new ChineseLunisolarCalendar();
        var dateTime = new DateTime(2023, 8, 16, 12, 41, 23);

        var year = calendar.GetYearInChinese(dateTime);
        Assert.AreEqual("二〇二三", year);
        year = calendar.GetYearInChinese(dateTime, zero: '零');
        Assert.AreEqual("二零二三", year);
    }

    [TestMethod()]
    public void GetMonthInChineseTest()
    {
        var calendar = new ChineseLunisolarCalendar();

        var dateTime = new DateTime(2023, 8, 16, 12, 41, 23);
        var month = calendar.GetMonthInChinese(dateTime);
        Assert.AreEqual("七", month);

        dateTime = new DateTime(2023, 4, 19, 12, 41, 23);
        month = calendar.GetMonthInChinese(dateTime);
        Assert.AreEqual("闰二", month);

        dateTime = new DateTime(2023, 2, 17, 12, 41, 23);
        month = calendar.GetMonthInChinese(dateTime);
        Assert.AreEqual("正", month);
        month = calendar.GetMonthInChinese(dateTime, useZhengFor1: false);
        Assert.AreEqual("一", month);

        dateTime = new DateTime(2023, 12, 15, 12, 41, 23);
        month = calendar.GetMonthInChinese(dateTime);
        Assert.AreEqual("十一", month);
        month = calendar.GetMonthInChinese(dateTime, useDongFor11: true);
        Assert.AreEqual("冬", month);

        dateTime = new DateTime(2024, 1, 17, 12, 41, 23);
        month = calendar.GetMonthInChinese(dateTime);
        Assert.AreEqual("十二", month);
        month = calendar.GetMonthInChinese(dateTime, useLaFor12: true);
        Assert.AreEqual("腊", month);
    }

    [TestMethod()]
    public void GetDayInChineseTest()
    {
        var calendar = new ChineseLunisolarCalendar();
        var dateTime = new DateTime(2023, 8, 15, 12, 41, 23);

        var day = calendar.GetDayInChinese(dateTime);
        Assert.AreEqual("廿九", day);
        day = calendar.GetDayInChinese(dateTime, useNianFor20s: false);
        Assert.AreEqual("二十九", day);
    }
    #endregion
}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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