/// <summary> /// ヴァナ日付に任意の日付を足す /// </summary> /// <param name="iVanaTime"></param> /// <param name="iAddDays"></param> /// <returns></returns> public static VanaTime addVanaDay(VanaTime iVanaTime, int iAddDays = 1) { var ret = new VanaTime() { Year = iVanaTime.Year, Month = iVanaTime.Month, Day = iVanaTime.Day, Hour = iVanaTime.Hour, Minute = iVanaTime.Minute, Second = iVanaTime.Second, }; for (int i = 0; i < iAddDays; i++) { ret.Day++; if (ret.Day > 30) { ret.Day = 1; ret.Month++; } if (ret.Month > 12) { ret.Month = 1; ret.Year++; } } return(ret); }
/// <summary> /// ヴァナ日付より曜日を取得 /// </summary> /// <param name="iVanaDate"></param> /// <returns></returns> public static Weekday GetWeekdayFromVanaTime(VanaTime iVanaTime) { long vanaTicks = getVanaTicks(iVanaTime); double dayType = (byte)((vanaTicks % (8D * 24D * 60D * 60D)) / (24D * 60D * 60D)); return((Weekday)dayType); }
/// <summary> /// ヴァナ時間より月齢を取得 /// </summary> /// <param name="iVanaDate">ヴァナ日付</param> /// <returns>月齢</returns> public static MoonPhase GetMoonPhaseFromVanaTime(VanaTime iVanaTime) { long vanaTicks = getVanaTicks(iVanaTime); double moonPhase = (byte)((vanaTicks % (12D * 7D * 24D * 60D * 60D)) / (7D * 24D * 60D * 60D)); return((MoonPhase)moonPhase); }
/// <summary> /// 地球時間からヴァナ時間を取得 /// </summary> /// <param name="iEarthDate">地球時間</param> /// <returns>ヴァナ時間</returns> public static VanaTime GetVanaTimeFromEarthTime(DateTime iEarthDate) { //地球時間 2002/01/01 00:00:00 = 天晶暦 0886/01/01 00:00:00 //一年=360日 一ヶ月=30日 一日=24時間 一時間=60分 一分=60秒 var ret = new VanaTime(); DateTime baseDate = new DateTime(2002, 1, 1, 0, 0, 0); DateTime nowDate = new DateTime(iEarthDate.Year, iEarthDate.Month, iEarthDate.Day, iEarthDate.Hour, iEarthDate.Minute, iEarthDate.Second); long baseTicks = baseDate.Ticks / 10000000L; long nowTicks = nowDate.Ticks / 10000000L; long vanaTicks = (nowTicks - baseTicks) * 25L; //年 double year = vanaTicks / (360D * 24D * 60D * 60D); ret.Year = (uint)(Math.Floor(year) + 886D); //月 ret.Month = (byte)((vanaTicks % (360D * 24D * 60D * 60D)) / (30D * 24D * 60D * 60D) + 1); //日 ret.Day = (byte)((vanaTicks % (30D * 24D * 60D * 60D)) / (24D * 60D * 60D) + 1); //時 ret.Hour = (byte)((vanaTicks % (24D * 60D * 60D)) / (60D * 60D)); //分 ret.Minute = (byte)((vanaTicks % (60D * 60D)) / (60D)); //秒 ret.Second = (byte)(vanaTicks % 60D); //曜日 double dayType = (byte)((vanaTicks % (8D * 24D * 60D * 60D)) / (24D * 60D * 60D)); ret.DayType = (Weekday)dayType; //月齢 double moonPhase = (byte)((vanaTicks % (12D * 7D * 24D * 60D * 60D)) / (7D * 24D * 60D * 60D)); ret.MoonPhase = (MoonPhase)moonPhase; return(ret); }
/// <summary> /// ヴァナ時間のTicksを取得 /// </summary> /// <param name="iVanaDate">ヴァナ日付</param> /// <returns>Ticks</returns> private static long getVanaTicks(VanaTime iVanaTime) { long baseTicks = (886L * 360L * 24L * 60L * 60L) + (30L * 24L * 60L * 60L) + (24L * 60L * 60L); long vanaTicks = (iVanaTime.Year * 12L * 30L * 24L * 60L * 60L) + (iVanaTime.Month * 30L * 24L * 60L * 60L) + (iVanaTime.Day * 24L * 60L * 60L) + (iVanaTime.Hour * 60L * 60L) + (iVanaTime.Minute * 60L) + (long)iVanaTime.Second; return(vanaTicks - baseTicks); }
public VanaTime GetVanaTime() { VanaTime ret = new VanaTime(); ret.Year = api.VanaTime.CurrentYear; ret.Month = api.VanaTime.CurrentMonth; ret.Day = api.VanaTime.CurrentDay; ret.Hour = api.VanaTime.CurrentHour; ret.Minute = api.VanaTime.CurrentMinute; ret.Second = api.VanaTime.CurrentSecond; ret.DayType = (Weekday)api.VanaTime.CurrentDay; ret.MoonPhase = (MoonPhase)api.VanaTime.CurrentMoonPhase; ret.MoonPercent = api.VanaTime.CurrentMoonPercent; return(ret); }
/// <summary> /// ヴァナ日付より地球日付を取得 /// </summary> /// <param name="iVanaDate"></param> /// <returns></returns> public static DateTime GetEarthTimeFromVanaTime(VanaTime iVanaTime) { //地球時間 2002/01/01 00:00:00 = 天晶暦 0886/01/01 00:00:00 //一年=360日 一ヶ月=30日 一日=24時間 一時間=60分 一分=60秒 long baseTicks = (886L * 360L * 24L * 60L * 60L) + (30L * 24L * 60L * 60L) + (24L * 60L * 60L); long vanaTicks = (iVanaTime.Year * 12L * 30L * 24L * 60L * 60L) + (iVanaTime.Month * 30L * 24L * 60L * 60L) + (iVanaTime.Day * 24L * 60L * 60L) + (iVanaTime.Hour * 60L * 60L) + (iVanaTime.Minute * 60L) + (long)iVanaTime.Second; long addseconds = (((vanaTicks - baseTicks) / 25L)); DateTime ret = new DateTime(2002, 1, 1, 0, 0, 0); ret = ret.AddSeconds(addseconds); return(ret); }