Exemplo n.º 1
0
        /// <summary>
        /// Create a new Wurm date/time object
        /// </summary>
        /// <param name="year">0 to 99999</param>
        /// <param name="starfall">starfall name</param>
        /// <param name="week">1 to 4</param>
        /// <param name="day">day name</param>
        /// <param name="hour">0 to 23</param>
        /// <param name="minute">0 to 59</param>
        /// <param name="second">0 to 59</param>
        public WurmDateTime(int year, WurmStarfall starfall, int week, WurmDay day, int hour, int minute, int second)
        {
            ValidateParameter(0, 99999, year, "year");
            ValidateParameter(1, 4, week, "week");
            ValidateParameter(0, 23, hour, "hour");
            ValidateParameter(0, 59, minute, "minute");
            ValidateParameter(0, 59, second, "second");
            // starfalls and days should be validated in their constructors

            this.second   = second;
            this.minute   = minute;
            this.hour     = hour;
            this.day      = day;
            this.week     = week;
            this.starfall = starfall;
            this.year     = year;

            totalseconds  = second;
            totalseconds += minute * MinuteSecs;
            totalseconds += hour * HourSecs;
            totalseconds += (day.Number - 1) * DaySecs;
            totalseconds += (week - 1) * WeekSecs;
            totalseconds += (starfall.Number - 1) * StarfallSecs;
            totalseconds += year * (long)YearSecs;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Construct Wurm date/time from total wurm seconds value
        /// </summary>
        /// <param name="totalseconds"></param>
        public WurmDateTime(long totalseconds)
        {
            this.totalseconds = totalseconds;

            int yearNum = (int)(totalseconds / YearSecs);

            totalseconds -= (long)yearNum * YearSecs;

            int starfallNum = (int)(totalseconds / StarfallSecs);

            totalseconds -= starfallNum * StarfallSecs;

            int weekNum = (int)(totalseconds / WeekSecs);

            totalseconds -= weekNum * WeekSecs;

            int dayNum = (int)(totalseconds / DaySecs);

            totalseconds -= dayNum * DaySecs;

            int hourNum = (int)(totalseconds / HourSecs);

            totalseconds -= hourNum * HourSecs;

            int minuteNum = (int)(totalseconds / MinuteSecs);

            totalseconds -= minuteNum * MinuteSecs;

            int secondNum = (int)totalseconds;

            second   = secondNum;
            minute   = minuteNum;
            hour     = hourNum;
            day      = new WurmDay(dayNum + 1);
            week     = weekNum + 1;
            starfall = new WurmStarfall(starfallNum + 1);
            year     = yearNum;
        }