v1.2.13.0 佛历新增27宿;修复宜忌重复的问题;修复获取气时缺冬至的问题;南京大屠杀纪念日改为国家公祭日。

This commit is contained in:
6tail
2021-12-16 10:35:29 +08:00
parent 480bc529e9
commit 42a82e7a66
11 changed files with 214 additions and 15 deletions

View File

@@ -151,6 +151,69 @@ namespace com.nlf.calendar
return false;
}
/// <summary>
/// 获取星宿
/// </summary>
/// <returns>星宿</returns>
public string getXiu()
{
return FotoUtil.getXiu(getMonth(), getDay());
}
/// <summary>
/// 获取宿吉凶
/// </summary>
/// <returns>吉凶</returns>
public string getXiuLuck()
{
return LunarUtil.XIU_LUCK[getXiu()];
}
/// <summary>
/// 获取宿歌诀
/// </summary>
/// <returns>星宿歌诀</returns>
public string getXiuSong()
{
return LunarUtil.XIU_SONG[getXiu()];
}
/// <summary>
/// 获取政
/// </summary>
/// <returns>政</returns>
public string getZheng()
{
return LunarUtil.ZHENG[getXiu()];
}
/// <summary>
/// 获取动物
/// </summary>
/// <returns>动物</returns>
public string getAnimal()
{
return LunarUtil.ANIMAL[getXiu()];
}
/// <summary>
/// 获取宫
/// </summary>
/// <returns>宫</returns>
public string getGong()
{
return LunarUtil.GONG[getXiu()];
}
/// <summary>
/// 获取兽
/// </summary>
/// <returns>兽</returns>
public string getShou()
{
return LunarUtil.SHOU[getGong()];
}
public string toString()
{
return getYearInChinese() + "年" + getMonthInChinese() + "月" + getDayInChinese();

View File

@@ -850,9 +850,9 @@ namespace com.nlf.calendar
public string getJie()
{
string jie = "";
for (int i = 1, j = JIE_QI.Length; i < j; i += 2)
for (int i = 0, j = JIE_QI_IN_USE.Length; i < j; i += 2)
{
string key = JIE_QI[i];
string key = JIE_QI_IN_USE[i];
Solar d = jieQi[key];
if (d.getYear() == solar.getYear() && d.getMonth() == solar.getMonth() && d.getDay() == solar.getDay())
{
@@ -870,9 +870,9 @@ namespace com.nlf.calendar
public string getQi()
{
string qi = "";
for (int i = 0, j = JIE_QI.Length; i < j; i += 2)
for (int i = 1, j = JIE_QI_IN_USE.Length; i < j; i += 2)
{
string key = JIE_QI[i];
string key = JIE_QI_IN_USE[i];
Solar d = jieQi[key];
if (d.getYear() == solar.getYear() && d.getMonth() == solar.getMonth() && d.getDay() == solar.getDay())
{

View File

@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
//
// 可以指定所有这些值,也可以使用“修订号”和“内部版本号”的默认值,
// 方法是按如下所示使用“*”:
[assembly: AssemblyVersion("1.2.12.0")]
[assembly: AssemblyFileVersion("1.2.12.0")]
[assembly: AssemblyVersion("1.2.13.0")]
[assembly: AssemblyFileVersion("1.2.13.0")]

23
lunar/lunar-csharp.csproj Normal file
View File

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Title>lunar-csharp</Title>
<Authors>6tail</Authors>
<Company>6tail</Company>
<Summary>a calendar library for Solar and Chinese Lunar</Summary>
<PackageTags>日历;公历;阳历;农历;阴历;老黄历;佛历;道历;法定假日</PackageTags>
<Description>日历、公历(阳历)、农历(阴历、老黄历)、佛历、道历,节假日、星座、儒略日、干支、生肖、节气、节日、彭祖百忌、每日宜忌、吉神宜趋凶煞宜忌、吉神(喜神/福神/财神/阳贵神/阴贵神)方位、胎神方位、冲煞、纳音、星宿、八字、五行、十神、建除十二值星、青龙名堂等十二神、黄道日及吉凶等。</Description>
<PackageReleaseNotes>新增道历Tao。</PackageReleaseNotes>
<Copyright>版权所有 (c) 2021</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>http://6tail.cn/calendar/api.html</PackageProjectUrl>
<RepositoryUrl>https://github.com/6tail/lunar-csharp.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Version>1.2.13.0</Version>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Properties\AssemblyInfo.cs" />
</ItemGroup>
</Project>

View File

@@ -257,5 +257,26 @@ namespace com.nlf.calendar.util
FESTIVAL.Add("12-29", new List<FotoFestival>(new FotoFestival[] { new FotoFestival("华严菩萨诞"), T }));
FESTIVAL.Add("12-30", new List<FotoFestival>(new FotoFestival[] { new FotoFestival("诸神下降,察访善恶", "犯者男女俱亡") }));
}
/// <summary>
/// 27星宿佛教从印度传入中国印度把28星宿改为27星宿把牛宿(牛金牛)纳入了女宿(女土蝠)。
/// </summary>
public static readonly string[] XIU_27 = { "角", "亢", "氐", "房", "心", "尾", "箕", "斗", "女", "虚", "危", "室", "壁", "奎", "娄", "胃", "昴", "毕", "觜", "参", "井", "鬼", "柳", "星", "张", "翼", "轸" };
/// <summary>
/// 每月初一的27星宿偏移
/// </summary>
private static readonly int[] XIU_OFFSET = { 11, 13, 15, 17, 19, 21, 24, 0, 2, 4, 7, 9 };
/// <summary>
/// 获取27星宿
/// </summary>
/// <param name="month">佛历月</param>
/// <param name="day">佛历日</param>
/// <returns>星宿</returns>
public static string getXiu(int month, int day)
{
return XIU_27[(XIU_OFFSET[Math.Abs(month) - 1] + day - 1) % XIU_27.Length];
}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -113,7 +113,7 @@ namespace com.nlf.calendar.util
OTHER_FESTIVAL.Add("11-28", new List<string>(new string[] { "恩格斯诞辰纪念日" }));
OTHER_FESTIVAL.Add("12-1", new List<string>(new string[] { "世界艾滋病日" }));
OTHER_FESTIVAL.Add("12-12", new List<string>(new string[] { "西安事变纪念日" }));
OTHER_FESTIVAL.Add("12-13", new List<string>(new string[] { "南京大屠杀纪念日" }));
OTHER_FESTIVAL.Add("12-13", new List<string>(new string[] { "国家公祭日" }));
OTHER_FESTIVAL.Add("12-26", new List<string>(new string[] { "毛泽东诞辰纪念日" }));
}

View File

@@ -115,7 +115,7 @@ namespace test
int[] endYears = { 1988, 1998, 2008, 2018, 2028, 2038, 2048, 2058, 2068, 2078 };
int[] startAges = { 1, 7, 17, 27, 37, 47, 57, 67, 77, 87 };
int[] endAges = { 6, 16, 26, 36, 46, 56, 66, 76, 86, 96 };
String[] yearGanZhi = { "", "乙卯", "丙辰", "丁巳", "戊午", "己未", "庚申", "辛酉", "壬戌", "癸亥" };
string[] yearGanZhi = { "", "乙卯", "丙辰", "丁巳", "戊午", "己未", "庚申", "辛酉", "壬戌", "癸亥" };
Solar solar = new Solar(1983, 2, 15, 20, 0, 0);
Lunar lunar = solar.getLunar();
EightChar bazi = lunar.getEightChar();
@@ -146,7 +146,7 @@ namespace test
int[] years = { 1983, 1984, 1985, 1986, 1987, 1988 };
int[] ages = { 1, 2, 3, 4, 5, 6 };
String[] ganZhi = { "癸亥", "甲子", "乙丑", "丙寅", "丁卯", "戊辰" };
string[] ganZhi = { "癸亥", "甲子", "乙丑", "丙寅", "丁卯", "戊辰" };
LiuNian[] l = daYun[0].getLiuNian();
for (int i = 0, j = l.Length; i < j; i++)
{
@@ -158,7 +158,7 @@ namespace test
years = new int[] { 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038 };
ages = new int[] { 47, 48, 49, 50, 51, 52, 53, 54, 55, 56 };
ganZhi = new String[] { "己酉", "庚戌", "辛亥", "壬子", "癸丑", "甲寅", "乙卯", "丙辰", "丁巳", "戊午" };
ganZhi = new string[] { "己酉", "庚戌", "辛亥", "壬子", "癸丑", "甲寅", "乙卯", "丙辰", "丁巳", "戊午" };
l = daYun[5].getLiuNian();
for (int i = 0, j = l.Length; i < j; i++)
{
@@ -183,7 +183,7 @@ namespace test
int[] years = { 1983, 1984, 1985, 1986, 1987, 1988 };
int[] ages = { 1, 2, 3, 4, 5, 6 };
String[] ganZhi = { "乙亥", "丙子", "丁丑", "戊寅", "己卯", "庚辰" };
string[] ganZhi = { "乙亥", "丙子", "丁丑", "戊寅", "己卯", "庚辰" };
XiaoYun[] l = daYun[0].getXiaoYun();
for (int i = 0, j = l.Length; i < j; i++)
{
@@ -195,7 +195,7 @@ namespace test
years = new int[] { 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038 };
ages = new int[] { 47, 48, 49, 50, 51, 52, 53, 54, 55, 56 };
ganZhi = new String[] { "辛酉", "壬戌", "癸亥", "甲子", "乙丑", "丙寅", "丁卯", "戊辰", "己巳", "庚午" };
ganZhi = new string[] { "辛酉", "壬戌", "癸亥", "甲子", "乙丑", "丙寅", "丁卯", "戊辰", "己巳", "庚午" };
l = daYun[5].getXiaoYun();
for (int i = 0, j = l.Length; i < j; i++)
{
@@ -218,7 +218,7 @@ namespace test
Yun yun = bazi.getYun(0);
DaYun[] daYun = yun.getDaYun();
String[] ganZhi = { "甲寅", "乙卯", "丙辰", "丁巳", "戊午", "己未", "庚申", "辛酉", "壬戌", "癸亥", "甲子", "乙丑" };
string[] ganZhi = { "甲寅", "乙卯", "丙辰", "丁巳", "戊午", "己未", "庚申", "辛酉", "壬戌", "癸亥", "甲子", "乙丑" };
LiuNian[] liuNian = daYun[0].getLiuNian();
LiuYue[] l = liuNian[0].getLiuYue();
for (int i = 0, j = l.Length; i < j; i++)
@@ -227,7 +227,7 @@ namespace test
Assert.AreEqual(ganZhi[i], liuYue.getGanZhi());
}
ganZhi = new String[] { "庚寅", "辛卯", "壬辰", "癸巳", "甲午", "乙未", "丙申", "丁酉", "戊戌", "己亥", "庚子", "辛丑" };
ganZhi = new string[] { "庚寅", "辛卯", "壬辰", "癸巳", "甲午", "乙未", "丙申", "丁酉", "戊戌", "己亥", "庚子", "辛丑" };
liuNian = daYun[4].getLiuNian();
l = liuNian[2].getLiuYue();
for (int i = 0, j = l.Length; i < j; i++)

View File

@@ -71,6 +71,17 @@ namespace test
Assert.AreEqual("二五六五年十月十四 (三元降) (四天王巡行)", foto.toFullString());
}
[TestMethod()]
public void test1()
{
Foto foto = Foto.fromLunar(Lunar.fromYmd(2020, 4, 13));
Assert.AreEqual("氐", foto.getXiu());
Assert.AreEqual("土", foto.getZheng());
Assert.AreEqual("貉", foto.getAnimal());
Assert.AreEqual("东", foto.getGong());
Assert.AreEqual("青龙", foto.getShou());
}
}

80
test/JieQiTest.cs Normal file
View File

@@ -0,0 +1,80 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Text;
using System.Collections.Generic;
using com.nlf.calendar;
using com.nlf.calendar.util;
namespace test
{
[TestClass()]
public class JieQiTest
{
private TestContext testContextInstance;
/// <summary>
///获取或设置测试上下文,上下文提供
///有关当前测试运行及其功能的信息。
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region
//
//编写测试时,可使用以下附加属性:
//
//使用 ClassInitialize 在运行类中的第一个测试前先运行代码
//
//[ClassInitialize()]
//public static void MyClassInitialize(TestContext testContext)
//{
//}
//
//使用 ClassCleanup 在运行完类中的所有测试后再运行代码
//
//[ClassCleanup()]
//public static void MyClassCleanup()
//{
//}
//
//使用 TestInitialize 在运行每个测试前先运行代码
//
//[TestInitialize()]
//public void MyTestInitialize()
//{
//}
//
//使用 TestCleanup 在运行完每个测试后运行代码
//
//[TestCleanup()]
//public void MyTestCleanup()
//{
//}
//
#endregion
[TestMethod()]
public void test()
{
Solar solar = Solar.fromYmd(2021, 12, 21);
Lunar luanr = solar.getLunar();
Assert.AreEqual("冬至", luanr.getJieQi());
Assert.AreEqual("", luanr.getJie());
Assert.AreEqual("冬至", luanr.getQi());
}
}
}

View File

@@ -55,6 +55,7 @@
<Compile Include="YearTest.cs" />
<Compile Include="FotoTest.cs" />
<Compile Include="TaoTest.cs" />
<Compile Include="JieQiTest.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="AuthoringTests.txt" />