/// <summary> /// 以儒略日初始化 /// </summary> /// <param name="JulianDay">儒略日</param> /// <param name="isMjd">是否是平儒略日</param> public Calendar(decimal JulianDay, bool isMjd = false) { if (isMjd) { JulianDay += 2400000.5m; } Int32 Day; Int32 Month; Int32 Year; Int32 Hour; Int32 Minute; Int32 Second; Decimal milliSeconds; TimeConvert.JdToCalendar(JulianDay, out Day, out Month, out Year, out Hour, out Minute, out Second, out milliSeconds); // this(Year, Month, Day, Hour, Minute, Second, milliSeconds); this.Year = Year; this.Month = Month; this.Day = Day; this.Hour = Hour; this.Minute = Minute; this.Second = Second; this.Seconds = Second + (milliSeconds / 1000.0M); this.MilliSeconds = milliSeconds; this.MilliSecond = (int)milliSeconds; this.SecondFraction = new SecondFraction(this.MilliSeconds / 1000M); }
public Calendar(int year, int dayOfYear, int hour, int minute, Decimal seconds) : this( year, TimeConvert.GetMonth(year, dayOfYear), TimeConvert.GetDayOfMonth(year, dayOfYear), hour, minute, seconds) { }
/// <summary> /// 将指定的日期和时间与另一个指定的日期和时间相减,返回一个时间间隔。 /// </summary> /// <param name="d1">System.Calendar(被减数)。</param> /// <param name="d2"> System.Calendar(减数)。</param> /// <returns>CalendarSpan,它是 d1 和 d2 之间的时间间隔,即 d1 减去 d2。</returns> public static CalendarSpan operator -(Calendar d1, Calendar d2) { return(CalendarSpan.FromDays(TimeConvert.GetPassedDays(d2, d1))); }