// ---------------------------------------------------------------------- public static void ShowAll( int periodCount, int year, YearMonth month, int day, int hour, int minuteValue ) { WriteLine( "Input: count={0}, year={1}, month={2}, day={3}, hour={4}, minute={5}", periodCount, year, month, day, hour, minuteValue ); WriteLine(); if ( periodCount == 1 ) { Minute minute = new Minute( year, (int)month, day, hour, minuteValue ); Minute previousMinute = minute.GetPreviousMinute(); Minute nextMinute = minute.GetNextMinute(); ShowMinute( minute ); ShowCompactMinute( previousMinute, "Previous Minute" ); ShowCompactMinute( nextMinute, "Next Minute" ); WriteLine(); } else { Minutes minutes = new Minutes( year, (int)month, day, hour, minuteValue, periodCount ); ShowMinutes( minutes ); WriteLine(); foreach ( Minute minute in minutes.GetMinutes() ) { ShowCompactMinute( minute ); } WriteLine(); } }
// ---------------------------------------------------------------------- public static void ShowMinute( Minute minute, string caption = "Minute" ) { WriteLine( "{0}: {1}", caption, minute ); WriteIndentLine( "Year: {0}", minute.Year ); WriteIndentLine( "Month: {0}", minute.Month ); WriteIndentLine( "Day: {0}", minute.Day ); WriteIndentLine( "Hour: {0}", minute.Hour ); WriteIndentLine( "MinuteValue: {0}", minute.MinuteValue ); WriteLine(); }
public void DefaultCalendarTest() { DateTime now = ClockProxy.Clock.Now; DateTime currentHour = new DateTime( now.Year, now.Month, now.Day, now.Hour, 0, 0 ); for ( int hourMinute = 0; hourMinute < TimeSpec.MinutesPerHour; hourMinute++ ) { Minute minute = new Minute( currentHour.AddMinutes( hourMinute ) ); Assert.AreEqual( minute.Year, currentHour.Year ); Assert.AreEqual( minute.Month, currentHour.Month ); Assert.AreEqual( minute.Month, currentHour.Month ); Assert.AreEqual( minute.Day, currentHour.Day ); Assert.AreEqual( minute.Hour, currentHour.Hour ); Assert.AreEqual( minute.MinuteValue, hourMinute ); Assert.AreEqual( minute.Start, currentHour.AddMinutes( hourMinute ).Add( minute.Calendar.StartOffset ) ); Assert.AreEqual( minute.End, currentHour.AddMinutes( hourMinute + 1 ).Add( minute.Calendar.EndOffset ) ); } }
public void AddMinutesTest() { DateTime now = ClockProxy.Clock.Now; DateTime nowMinute = new DateTime( now.Year, now.Month, now.Day, now.Hour, now.Minute, 0 ); Minute minute = new Minute( now, TimeCalendar.NewEmptyOffset() ); Assert.AreEqual( minute.AddMinutes( 0 ), minute ); DateTime previousMinute = nowMinute.AddMinutes( -1 ); Assert.AreEqual( minute.AddMinutes( -1 ).Year, previousMinute.Year ); Assert.AreEqual( minute.AddMinutes( -1 ).Month, previousMinute.Month ); Assert.AreEqual( minute.AddMinutes( -1 ).Day, previousMinute.Day ); Assert.AreEqual( minute.AddMinutes( -1 ).Hour, previousMinute.Hour ); Assert.AreEqual( minute.AddMinutes( -1 ).MinuteValue, previousMinute.Minute ); DateTime nextMinute = nowMinute.AddMinutes( 1 ); Assert.AreEqual( minute.AddMinutes( 1 ).Year, nextMinute.Year ); Assert.AreEqual( minute.AddMinutes( 1 ).Month, nextMinute.Month ); Assert.AreEqual( minute.AddMinutes( 1 ).Day, nextMinute.Day ); Assert.AreEqual( minute.AddMinutes( 1 ).Hour, nextMinute.Hour ); Assert.AreEqual( minute.AddMinutes( 1 ).MinuteValue, nextMinute.Minute ); }
// ---------------------------------------------------------------------- public static void ShowCompactMinute( Minute minute, string caption = "Minute" ) { WriteLine( "{0}: {1}", caption, minute ); }
// ---------------------------------------------------------------------- private void UpdateSelectedPeriodInfo() { TimeCalendar timeCalendar = TimeCalendar.New( SelectedYearBaseMonth ); switch ( SelectedPeriodMode ) { case TimePeriodMode.Year: Year year = new Year( WorkingDate, timeCalendar ); periodInfo.Clear(); periodInfo.AddItem( "Year", year ); periodInfo.AddItem( "YearBaseMonth", year.YearBaseMonth ); periodInfo.AddItem( "IsCalendarYear", year.IsCalendarYear ); periodInfo.AddItem( "StartYear", year.StartYear ); periodInfo.AddItem( "FirstDayStart", year.FirstDayStart ); periodInfo.AddItem( "LastDayStart", year.LastDayStart ); periodInfo.AddItem( "LastMonthStart", year.LastMonthStart ); periodInfo.AddItem( "YearName", year.YearName ); periodInfo.AddSection( "Previous/Next" ); periodInfo.AddItem( "Previous", year.GetPreviousYear() ); periodInfo.AddItem( "Next", year.GetNextYear() ); periodInfo.AddSubitems( "Halfyears", year.GetHalfyears() ); periodInfo.AddSubitems( "Quarters", year.GetQuarters() ); periodInfo.AddSubitems( "Months", year.GetMonths() ); SelectedPeriodInfo = periodInfo.ToString(); break; case TimePeriodMode.Halfyear: Halfyear halfyear = new Halfyear( WorkingDate, timeCalendar ); periodInfo.Clear(); periodInfo.AddItem( "Halfyear", halfyear ); periodInfo.AddItem( "YearBaseMonth", halfyear.YearBaseMonth ); periodInfo.AddItem( "StartMonth", halfyear.StartMonth ); periodInfo.AddItem( "Year", halfyear.Year ); periodInfo.AddItem( "YearHalfyear", halfyear.YearHalfyear ); periodInfo.AddItem( "IsCalendarHalfyear", halfyear.IsCalendarHalfyear ); periodInfo.AddItem( "MultipleCalendarYears", halfyear.MultipleCalendarYears ); periodInfo.AddItem( "HalfyearName", halfyear.HalfyearName ); periodInfo.AddItem( "HalfyearOfYearName", halfyear.HalfyearOfYearName ); periodInfo.AddItem( "LastDayStart", halfyear.LastDayStart ); periodInfo.AddItem( "LastMonthStart", halfyear.LastMonthStart ); periodInfo.AddSection( "Previous/Next" ); periodInfo.AddItem( "Previousr", halfyear.GetPreviousHalfyear() ); periodInfo.AddItem( "Next", halfyear.GetNextHalfyear() ); periodInfo.AddSubitems( "Quarters", halfyear.GetQuarters() ); periodInfo.AddSubitems( "Months", halfyear.GetMonths() ); SelectedPeriodInfo = periodInfo.ToString(); break; case TimePeriodMode.Quarter: Quarter quarter = new Quarter( WorkingDate, timeCalendar ); periodInfo.Clear(); periodInfo.AddItem( "Quarter", quarter ); periodInfo.AddItem( "YearBaseMonth", quarter.YearBaseMonth ); periodInfo.AddItem( "StartMonth", quarter.StartMonth ); periodInfo.AddItem( "Year", quarter.Year ); periodInfo.AddItem( "YearQuarter", quarter.YearQuarter ); periodInfo.AddItem( "IsCalendarQuarter", quarter.IsCalendarQuarter ); periodInfo.AddItem( "MultipleCalendarYears", quarter.MultipleCalendarYears ); periodInfo.AddItem( "QuarterName", quarter.QuarterName ); periodInfo.AddItem( "QuarterOfYearName", quarter.QuarterOfYearName ); periodInfo.AddItem( "LastDayStart", quarter.FirstDayStart ); periodInfo.AddItem( "LastMonthStart", quarter.LastDayStart ); periodInfo.AddSection( "Previous/Next" ); periodInfo.AddItem( "Previous", quarter.GetPreviousQuarter() ); periodInfo.AddItem( "Next", quarter.GetNextQuarter() ); periodInfo.AddSubitems( "Months", quarter.GetMonths() ); SelectedPeriodInfo = periodInfo.ToString(); break; case TimePeriodMode.Month: Month month = new Month( WorkingDate, timeCalendar ); periodInfo.Clear(); periodInfo.AddItem( "Month", month ); periodInfo.AddItem( "YearBaseMonth", month.YearMonth ); periodInfo.AddItem( "Year", month.Year ); periodInfo.AddItem( "DaysInMonth", month.DaysInMonth ); periodInfo.AddItem( "MonthName", month.MonthName ); periodInfo.AddItem( "MonthOfYearName", month.MonthOfYearName ); periodInfo.AddItem( "LastDayStart", month.FirstDayStart ); periodInfo.AddItem( "LastMonthStart", month.LastDayStart ); periodInfo.AddSection( "Previous/Next" ); periodInfo.AddItem( "Previous", month.GetPreviousMonth() ); periodInfo.AddItem( "Next", month.GetNextMonth() ); periodInfo.AddSubitems( "Days", month.GetDays() ); SelectedPeriodInfo = periodInfo.ToString(); break; case TimePeriodMode.Week: Week week = new Week( WorkingDate, timeCalendar ); periodInfo.Clear(); periodInfo.AddItem( "Week", week ); periodInfo.AddItem( "MultipleCalendarYears", week.MultipleCalendarYears ); periodInfo.AddItem( "FirstDayStart", week.FirstDayStart ); periodInfo.AddItem( "FirstDayOfWeek", week.FirstDayOfWeek ); periodInfo.AddItem( "LastDayStart", week.LastDayStart ); periodInfo.AddItem( "LastDayOfWeek", week.LastDayOfWeek ); periodInfo.AddItem( "WeekOfYear", week.WeekOfYear ); periodInfo.AddItem( "WeekOfYearName", week.WeekOfYearName ); periodInfo.AddSection( "Previous/Next" ); periodInfo.AddItem( "Previous", week.GetPreviousWeek() ); periodInfo.AddItem( "Next", week.GetNextWeek() ); periodInfo.AddSubitems( "Days", week.GetDays() ); SelectedPeriodInfo = periodInfo.ToString(); break; case TimePeriodMode.Day: Day day = new Day( WorkingDate, timeCalendar ); periodInfo.Clear(); periodInfo.AddItem( "Day", day ); periodInfo.AddItem( "Year", day.Year ); periodInfo.AddItem( "FirstDayStart", day.FirstDayStart ); periodInfo.AddItem( "Month", day.Month ); periodInfo.AddItem( "DayValue", day.DayValue ); periodInfo.AddItem( "DayOfWeek", day.DayOfWeek ); periodInfo.AddItem( "DayName", day.DayName ); periodInfo.AddItem( "FirstHourStart", day.FirstHourStart ); periodInfo.AddItem( "LastHourStart", day.LastHourStart ); periodInfo.AddSection( "Previous/Next" ); periodInfo.AddItem( "Previous", day.GetPreviousDay() ); periodInfo.AddItem( "Next", day.GetNextDay() ); periodInfo.AddSubitems( "Hours", day.GetHours() ); SelectedPeriodInfo = periodInfo.ToString(); break; case TimePeriodMode.Hour: Hour hour = new Hour( WorkingDate, timeCalendar ); periodInfo.Clear(); periodInfo.AddItem( "Hour", hour ); periodInfo.AddItem( "Year", hour.Year ); periodInfo.AddItem( "Month", hour.Month ); periodInfo.AddItem( "Day", hour.Day ); periodInfo.AddItem( "HourValue", hour.HourValue ); periodInfo.AddItem( "FirstMinuteStart", hour.FirstMinuteStart ); periodInfo.AddItem( "LastMinuteStart", hour.LastMinuteStart ); periodInfo.AddSection( "Previous/Next" ); periodInfo.AddItem( "Previous", hour.GetPreviousHour() ); periodInfo.AddItem( "Next", hour.GetNextHour() ); periodInfo.AddSubitems( "Minutes", hour.GetMinutes() ); SelectedPeriodInfo = periodInfo.ToString(); break; case TimePeriodMode.Minute: Minute minute = new Minute( WorkingDate, timeCalendar ); periodInfo.Clear(); periodInfo.AddItem( "Minute", minute ); periodInfo.AddItem( "Year", minute.Year ); periodInfo.AddItem( "Month", minute.Month ); periodInfo.AddItem( "Day", minute.Day ); periodInfo.AddItem( "Hour", minute.Hour ); periodInfo.AddItem( "MinuteValue", minute.MinuteValue ); periodInfo.AddSection( "Previous/Next" ); periodInfo.AddItem( "Previous", minute.GetPreviousMinute() ); periodInfo.AddItem( "Next", minute.GetNextMinute() ); SelectedPeriodInfo = periodInfo.ToString(); break; } }
public void GetNextMinuteTest() { Minute minute = new Minute(); Assert.AreEqual( minute.GetNextMinute(), minute.AddMinutes( 1 ) ); }
public void InitValuesTest() { DateTime now = ClockProxy.Clock.Now; DateTime firstMinute = new DateTime( now.Year, now.Month, now.Day, now.Hour, now.Minute, 0 ); DateTime secondMinute = firstMinute.AddMinutes( 1 ); Minute minute = new Minute( now, TimeCalendar.NewEmptyOffset() ); Assert.AreEqual( minute.Start.Year, firstMinute.Year ); Assert.AreEqual( minute.Start.Month, firstMinute.Month ); Assert.AreEqual( minute.Start.Day, firstMinute.Day ); Assert.AreEqual( minute.Start.Hour, firstMinute.Hour ); Assert.AreEqual( minute.Start.Minute, firstMinute.Minute ); Assert.AreEqual( minute.Start.Second, 0 ); Assert.AreEqual( minute.Start.Millisecond, 0 ); Assert.AreEqual( minute.End.Year, secondMinute.Year ); Assert.AreEqual( minute.End.Month, secondMinute.Month ); Assert.AreEqual( minute.End.Day, secondMinute.Day ); Assert.AreEqual( minute.End.Hour, secondMinute.Hour ); Assert.AreEqual( minute.End.Minute, secondMinute.Minute ); Assert.AreEqual( minute.End.Second, 0 ); Assert.AreEqual( minute.End.Millisecond, 0 ); }
public void GetPreviousMinuteTest() { Minute minute = new Minute(); Assert.AreEqual( minute.GetPreviousMinute(), minute.AddMinutes( -1 ) ); }
} // Equals // ---------------------------------------------------------------------- public override string ToString() { return(((int)TotalHours).ToString("00") + ":" + Minute.ToString("00") + ":" + Second.ToString("00") + "." + Millisecond.ToString("000")); } // ToString