/// <summary> /// 地球時間をエオルゼア時間に変換する /// </summary> /// <param name="localTime"> /// 地球の現地時間</param> /// <returns> /// エオルゼア時間</returns> public static EorzeaTime ToEorzeaTime( DateTimeOffset localTime) { // UTCにおける差分を算出する var diff = localTime.ToUniversalTime() - EorzeaTimeOriginByUTC; var totalSec = diff.TotalSeconds; var delta = totalSec * LTETRatio; var secound = (int)Math.Truncate(delta % 60d); delta -= secound; delta /= 60.0d; var minute = (int)Math.Truncate(delta % 60d); delta -= minute; delta /= 60.0d; var hour = (int)Math.Truncate(delta % 24d); delta -= hour; delta /= 24.0d; var day = (int)Math.Truncate(delta % 32d); delta -= day; delta /= 32.0d; var month = (int)Math.Truncate(delta % 12d); delta -= month; delta /= 12.0d; var year = (int)Math.Truncate(delta); // 年月日は1オリジンなので1を加える var et = new EorzeaTime(); et.Year = (1 + year) % 10000; et.Month = 1 + month; et.Day = 1 + day; et.Hour = hour; et.Minute = minute; et.Second = 0; return(et); }
public static DateTimeOffset FromEorzeaTime( EorzeaTime eorzeaTime) { var delta = 0d; delta += (eorzeaTime.Year - 1) * 12 * 32 * 24 * 60 * 60; delta += (eorzeaTime.Month - 1) * 32 * 24 * 60 * 60; delta += (eorzeaTime.Day - 1) * 24 * 60 * 60; delta += eorzeaTime.Hour * 60 * 60; delta += eorzeaTime.Minute * 60; delta += eorzeaTime.Second; var totalSec = delta / LTETRatio; var utc = EorzeaTimeOriginByUTC.AddSeconds(totalSec); return(utc.ToLocalTime()); }