Example #1
0
        public static Duration GetDurationFromChristBirth(PartialDateInfo dateInfo)
        {
            long hours = 0;

            if (dateInfo.Era == Era.AnnoDomini)
            {
                hours += HoursInYear * (dateInfo.Year - 1); // There is no zero year.
            }
            else
            {
                hours = HoursInYear * (-dateInfo.Year);
            }

            if (dateInfo.Month.HasValue)
            {
                hours += HoursInMonth * (dateInfo.Month.Value - 1);

                if (dateInfo.Day.HasValue)
                {
                    hours += HoursInDay * (dateInfo.Day.Value - 1);

                    if (dateInfo.Hour.HasValue)
                    {
                        hours += dateInfo.Hour.Value;
                    }
                }
            }

            return(new Duration(hours));
        }
Example #2
0
 public SpecificDate(Era era, long year, int?month = null, int?day = null, int?hour = null)
 {
     _dateInfo = new PartialDateInfo(era, year, month, day, hour);
 }
Example #3
0
        protected override PartialDateInfo GetDateInfo()
        {
            var now = DateTime.Now;

            return(PartialDateInfo.AnnoDomini(now.Year, now.Month, now.Day, now.Hour));
        }