Ozakboy.TaiwanKit.Ganzhi.NET 1.0.1

dotnet add package Ozakboy.TaiwanKit.Ganzhi.NET --version 1.0.1
                    
NuGet\Install-Package Ozakboy.TaiwanKit.Ganzhi.NET -Version 1.0.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="Ozakboy.TaiwanKit.Ganzhi.NET" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ozakboy.TaiwanKit.Ganzhi.NET" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Ozakboy.TaiwanKit.Ganzhi.NET" />
                    
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 Ozakboy.TaiwanKit.Ganzhi.NET --version 1.0.1
                    
#r "nuget: Ozakboy.TaiwanKit.Ganzhi.NET, 1.0.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.
#:package Ozakboy.TaiwanKit.Ganzhi.NET@1.0.1
                    
#: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=Ozakboy.TaiwanKit.Ganzhi.NET&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Ozakboy.TaiwanKit.Ganzhi.NET&version=1.0.1
                    
Install as a Cake Tool

<p align="center"> <img src="https://raw.githubusercontent.com/ozakboy/Ozakboy.TaiwanKit.Ganzhi.NET/main/logo.png" width="128" alt="Ozakboy.TaiwanKit logo" /> </p>

Ozakboy.TaiwanKit.Ganzhi.NET

繁體中文

Lunar calendar, 24 solar terms and Ganzhi (four pillars) conversion for .NET — covering 1901–2100, works fully offline, zero runtime dependencies.

Part of the Ozakboy.TaiwanKit series.

Features

  • Gregorian ↔ lunar conversion — leap months explicitly flagged (IsLeapMonth), non-existent dates rejected via TryToSolar
  • 24 solar terms with minute precision — transition times in Taiwan time (UTC+8), astronomically computed from the full-precision VSOP87D ephemeris and cross-verified against USNO equinox/solstice times and published almanac data
  • Ganzhi four pillars — year / month / day / hour pillars for Bazi use:
    • Year boundary selectable: LiChun exact time (default, fortune-telling convention) or Lunar New Year (folk convention)
    • Month pillars switch at exact solar-term times (five-tigers stem rule)
    • Day pillar anchored to two independently verified dates; hour pillar with the 23:00 late-Zi rule
  • Zodiac — with the same selectable year boundary
  • Lunar festivals — New Year's Eve, Lunar New Year, Lantern, Dragon Boat, Qixi, Ghost, Mid-Autumn, Double Ninth, Laba (incl. its two-or-zero-per-year edge case) and DongZhi

Install

dotnet add package Ozakboy.TaiwanKit.Ganzhi.NET

Supported frameworks: netstandard2.0 / netstandard2.1 / net8.0 / net9.0 / net10.0

Quick start

using Ozakboy.TaiwanKit.Ganzhi.NET;

// --- Lunar conversion ---
LunarDate lunar = LunarConverter.ToLunar(new DateTime(2026, 2, 17));
// lunar.Year=2026, Month=1, Day=1, IsLeapMonth=false → "2026年正月初一"

DateTime solar = LunarConverter.ToSolar(new LunarDate(2026, 8, 15));  // Mid-Autumn → 2026-09-25
LunarConverter.GetLeapMonth(2025);                                     // 6 (leap 6th month)

// --- Solar terms (minute precision, Taiwan time) ---
SolarTerms.GetExactTime(2026, SolarTerm.LiChun);      // 2026-02-04 04:02
SolarTerms.GetCurrentTerm(new DateTime(2026, 2, 10)); // LiChun (governing term)

// --- Ganzhi four pillars ---
FourPillars p = GanzhiCalendar.GetFourPillars(new DateTime(2026, 2, 20, 10, 0, 0));
// p.ToString() → "丙午 庚寅 [day] [hour]"

GanzhiCalendar.GetYearGanzhi(new DateTime(2026, 2, 10));                            // 丙午 (LiChun boundary)
GanzhiCalendar.GetYearGanzhi(new DateTime(2026, 2, 10), YearBoundary.LunarNewYear); // 乙巳 (folk boundary)
GanzhiCalendar.GetZodiac(new DateTime(2026, 6, 1));                                 // Zodiac.Horse

// --- Lunar festivals ---
LunarFestivals.TryGetFestival(new DateTime(2026, 6, 19), out var f);  // true, DragonBoat
LunarFestivals.GetFestivalDate(2026, LunarFestival.MidAutumn);        // 2026-09-25

API overview

Type Highlights
LunarConverter ToLunar / ToSolar / TryToSolar / GetLeapMonth; range 1901-02-19 ~ 2101-01-28
SolarTerms GetYearTerms(year) / GetExactTime(year, term) / GetCurrentTerm(moment) / TryGetTermOfDay(date); 1901–2100
GanzhiCalendar GetYearGanzhi / GetMonthGanzhi / GetDayGanzhi / GetHourGanzhi / GetFourPillars / GetZodiac; 1901-02-19 ~ 2100-12-31
LunarFestivals TryGetFestival(date) / GetFestivalDate(year, festival)
LunarDate / GanzhiValue / FourPillars / SolarTermInfo Immutable value objects with Chinese names (ChineseName, ToString)

Semantics worth knowing

  • All times are Taiwan time (UTC+8); no time-zone conversion is performed.
  • Year pillar boundary: default is the exact LiChun minute. 2026-02-04 04:01 → 乙巳, 04:02 → 丙午.
  • Day pillar (GetDayGanzhi) uses the civil date (switches at 00:00). GetFourPillars applies the Bazi convention: from 23:00 the day pillar belongs to the next day.
  • Leap months never count as festivals (a leap-5th-month 5th day is not Dragon Boat).
  • Out-of-range queries throw — the library never extrapolates the calendar.

Data accuracy

  • Lunar conversion is backed by .NET's ChineseLunisolarCalendar (Microsoft-maintained, 1901–2100).
  • The solar term table is generated offline from the full-precision VSOP87D ephemeris (IAU1980 nutation main terms, Espenak–Meeus ΔT), rounded to the minute, and verified against:
    • USNO-published equinox/solstice times (2000: 4/4 exact)
    • Purple-Mountain-Observatory-sourced almanac times (2025: 3/3 exact)
    • Multi-source cross-check of all 24 terms of 2026 (24/24)

Ozakboy.TaiwanKit series

Package Description
Ozakboy.TaiwanKit.TwIdValidator Taiwan ID / BAN / mobile number validation
Ozakboy.TaiwanKit.TaiwanHolidays Taiwan national holidays / make-up workday queries
Ozakboy.TaiwanKit.Ganzhi.NET Lunar calendar / solar terms / Ganzhi conversion (this package)
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 is compatible.  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 is compatible.  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 is compatible.  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 is compatible. 
.NET Framework 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.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.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.1 98 7/5/2026
1.0.0 100 7/5/2026

Added the Ozakboy.TaiwanKit series logo as the NuGet package icon and README header. Changelog: https://github.com/ozakboy/Ozakboy.TaiwanKit.Ganzhi.NET/blob/main/docs/en/changelog.md