public TimespanRuleOutOfRangeException(string message, TimeSpan dayTimeFrom, TimeSpan dayTimeTo, DaysOfWeek daysOfWeek) : base(message) { DayTimeFrom = dayTimeFrom; DayTimeTo = dayTimeTo; DaysOfWeek = daysOfWeek; }
public void SerializeTest() { var mockRepository = new MockRepository(MockBehavior.Strict); var mockTimeSpan = mockRepository.Create<IStringSerializer<TimeSpan>>(); var mockDaysOfWeek = mockRepository.Create<IStringSerializer<DaysOfWeek>>(); var mockIEnumerableDateTime = mockRepository.Create<IStringSerializer<IEnumerable<DateTime>>>(); var timeSpanRuleInfoSerializer = new TimeSpanRuleInfoSerializer(mockTimeSpan.Object, mockDaysOfWeek.Object, mockIEnumerableDateTime.Object); var expMin = new TimeSpan(150); var expMax = new TimeSpan(250); var expDaysOfWeek = new DaysOfWeek(DayOfWeek.Monday, DayOfWeek.Thursday); var expDateTimes = new[] {new DateTime(1), new DateTime(100), new DateTime(500)}; var exp = new TimeSpanRuleInfo(expMin, expMax, expDaysOfWeek, expDateTimes); mockTimeSpan.Setup(x => x.Serialize(expMin)).Returns("150").Verifiable(); mockTimeSpan.Setup(x => x.Serialize(expMax)).Returns("250").Verifiable(); mockDaysOfWeek.Setup(x => x.Serialize(expDaysOfWeek)).Returns("1,4").Verifiable(); mockIEnumerableDateTime.Setup(x => x.Serialize(expDateTimes)).Returns("datetimes").Verifiable(); Assert.AreEqual("150\x001E250\x001E1,4\x001Edatetimes", timeSpanRuleInfoSerializer.Serialize(exp)); mockRepository.VerifyAll(); }
/// <summary> /// Initializes a new instance of the <see cref="OpeningHoursSpecification"/> class. /// </summary> /// <param name="closes">The closes.</param> /// <param name="dayOfWeek">The day of week.</param> /// <param name="opens">The opens.</param> /// <param name="validFrom">The valid from.</param> /// <param name="validThrough">The valid through.</param> public OpeningHoursSpecification(string closes, DaysOfWeek dayOfWeek, string opens, string validFrom = null, string validThrough = null) { Closes = closes; DayOfWeek = dayOfWeek.ToString(); Opens = opens; ValidFrom = validFrom; ValidThrough = validThrough; }
protected CronExpression(DaysOfWeek days, int startHour, int startMinute, CronExpressionType expressionType) { _days = days; _startHour = startHour; _startMinute = startMinute; _expressionType = expressionType; BuildCronExpression(); }
public bool CheckDateTime(DateTime?dateTime = null) { var time = dateTime ?? DateTime.Now; return(Minutes.Contains(time.Minute) && Hours.Contains(time.Hour) && Months.Contains(time.Month - 1) && (DaysOfMonth.Contains(time.Day - 1) || DaysOfWeek.Contains((int)time.DayOfWeek - 1))); }
private static void Main(string[] args) { DaysOfWeek days = DaysOfWeek.Wednesday | DaysOfWeek.Monday; Console.WriteLine(days); bool test = (DaysOfWeek.Monday & DaysOfWeek.Wednesday) == DaysOfWeek.Wednesday; Console.WriteLine(test); }
static void Main(string[] args) { bool correctDay = false; // this sets up a text processor in the English-US format (or whatever the user chose) TextInfo textProcessor = new CultureInfo("en-US", true).TextInfo; //var actualDay = DaysOfWeek.Monday.ToString().ToLower(); // DateTime.Today is a standard Windows.NET library function that lets you get the date and time from your operating system DaysOfWeek today = (DaysOfWeek)Enum.Parse(typeof(DaysOfWeek), DateTime.Today.DayOfWeek.ToString()); Console.WriteLine("Enter what day it is today."); while (!correctDay) { try { string userInput = Console.ReadLine(); // we don't want them to use integers, BUT it won't return an error // so we need a custom statement to handle that and let them know // they need to not use just a number value if (int.TryParse(userInput, out int tempInt)) { Console.WriteLine("Please enter a day of the week, not a number."); } // we need this to happen if they use anything that translates to a string // i.e. 2butt // i.e. monday else { // use a special function of a TextInfo text processor object to make the text a specific capitalization style string capitalizedInput = textProcessor.ToTitleCase(userInput); DaysOfWeek userGuess = (DaysOfWeek)Enum.Parse(typeof(DaysOfWeek), capitalizedInput); if (userGuess == today) { Console.WriteLine("That is the correct day."); correctDay = true; } // I added this so the user knew if they entered the wrong thing instead of just cycling back to the top with no message else { Console.WriteLine("You entered the incorrect day; guess again!"); } } } catch (ArgumentException ex) { Console.WriteLine("Please enter a day of the week."); } catch (Exception ex) { Console.WriteLine("I don't know what you did, but here you are."); } } Console.ReadLine(); }
static void Main(string[] args) { DaysOfWeek today = DaysOfWeek.Wed; // wait for input before exiting Console.WriteLine("Press enter to finish"); Console.ReadLine(); }
public void ConvertFromEDaysOfWeekFlagsWithMultipleDays() { HashSet <EDaysOfWeek> weekendDays = DaysOfWeek.ConvertFrom(EDaysOfWeekFlags.Saturday ^ EDaysOfWeekFlags.Sunday); Assert.That(weekendDays, Is.Not.Empty); Assert.That(weekendDays.Count, Is.EqualTo(2)); Assert.That(weekendDays.Contains(EDaysOfWeek.Saturday), Is.True); Assert.That(weekendDays.Contains(EDaysOfWeek.Sunday), Is.True); }
public Recurrence(RecurrenceType type, uint interval, uint nthDayInMonth, DaysOfWeek daysOfWeek, WeekOrderInMonth weekOrderInMonth, uint monthOrder) { this.Type = type; this.Interval = interval; this.NthDayInMonth = nthDayInMonth; this.DaysOfWeek = daysOfWeek; this.WeekOrderInMonth = weekOrderInMonth; this.MonthOrder = monthOrder; }
internal AttendeeWorkHours(TimeSpan startTime, TimeSpan endTime, DaysOfWeek daysOfWeek, ExTimeZone exTimeZone) { AttendeeWorkHours.Validate(startTime, endTime); this.startTime = startTime; this.endTime = endTime; this.daysOfWeek = daysOfWeek; this.timeZone = exTimeZone; this.CalculateWorkDayInconvenience(); }
private static void EvaluateEnumDemo() { EmpType e2 = EmpType.Contractor; DaysOfWeek day = DaysOfWeek.Mon; ConsoleColor cc = ConsoleColor.Gray; EvaluateEnum(e2); EvaluateEnum(day); EvaluateEnum(cc); }
public RecurrenceDayOfWeek RemoveDayOfWeek(string dayOfWeek) { RecurrenceDayOfWeek day; if (Enum.TryParse(dayOfWeek, out day) && DaysOfWeek.Contains(day)) { DaysOfWeek.RemoveAll(item => item == day); } return(day); }
// Token: 0x0600056C RID: 1388 RVA: 0x0002AEE0 File Offset: 0x000290E0 private bool GetIsDaySelected(DayOfWeek dayOfWeek) { if (this.calendarItemData.Recurrence.Pattern is WeeklyRecurrencePattern) { DaysOfWeek daysOfWeek = CalendarUtilities.ConvertDayOfWeekToDaysOfWeek(dayOfWeek); WeeklyRecurrencePattern weeklyRecurrencePattern = (WeeklyRecurrencePattern)this.calendarItemData.Recurrence.Pattern; return((weeklyRecurrencePattern.DaysOfWeek & daysOfWeek) != DaysOfWeek.None); } return(false); }
/// <summary> /// Gets all the days of the week contained in the input string using a regular expression. /// </summary> public static DaysOfWeek GetDaysOfWeek(string days) { DaysOfWeek result = DaysOfWeek.None; foreach (Match match in m_dayOfWeekPattern.Matches(days)) { result |= ToDaysOfWeek(match.Value); } return(result); }
/// <summary> /// Returns a value indicating whether the provided DaysOfWeek value is applicable today. /// </summary> public static bool IsToday(DaysOfWeek days, TimeSpan lastArrivalTime, DateTimeOffset currentTime) { var normalizedArrivalTime = lastArrivalTime.Days == 1 ? lastArrivalTime - TimeSpan.FromDays(1) : lastArrivalTime; // if the last arrival time is later than the current time, this pushes the "effective day" back by one. // For example Sunday at 1 AM will have an "effective day" of Saturday when looking for the right Night Owl schedule. var effectiveDay = currentTime - normalizedArrivalTime; return((ToDaysOfWeek(effectiveDay.DayOfWeek) & days) != DaysOfWeek.None); }
protected RecurringSchedule(SerializationInfo info, StreamingContext context) { type = (RecurringScheduleUnit)info.GetValue("Type", typeof(RecurringScheduleUnit)); frequency = (int)info.GetValue("Frequency", typeof(int)); executionTime = (DateTime)info.GetValue("ExecutionTime", typeof(DateTime)); weeklySchedule = (DaysOfWeek)info.GetValue("WeeklySchedule", typeof(DaysOfWeek)); monthlySchedule = (int)info.GetValue("MonthlySchedule", typeof(int)); LastRun = (DateTime)info.GetDateTime("LastRun"); NextRunCache = (DateTime)info.GetDateTime("NextRun"); }
public void ConvertFromEDaysOfWeekFlags() { Assert.That(DaysOfWeek.ConvertFrom(EDaysOfWeekFlags.Monday).Single(), Is.EqualTo(EDaysOfWeek.Monday)); Assert.That(DaysOfWeek.ConvertFrom(EDaysOfWeekFlags.Tuesday).Single(), Is.EqualTo(EDaysOfWeek.Tuesday)); Assert.That(DaysOfWeek.ConvertFrom(EDaysOfWeekFlags.Wednesday).Single(), Is.EqualTo(EDaysOfWeek.Wednesday)); Assert.That(DaysOfWeek.ConvertFrom(EDaysOfWeekFlags.Thursday).Single(), Is.EqualTo(EDaysOfWeek.Thursday)); Assert.That(DaysOfWeek.ConvertFrom(EDaysOfWeekFlags.Friday).Single(), Is.EqualTo(EDaysOfWeek.Friday)); Assert.That(DaysOfWeek.ConvertFrom(EDaysOfWeekFlags.Saturday).Single(), Is.EqualTo(EDaysOfWeek.Saturday)); Assert.That(DaysOfWeek.ConvertFrom(EDaysOfWeekFlags.Sunday).Single(), Is.EqualTo(EDaysOfWeek.Sunday)); }
public static void TestNumberOfDaysUntil(this DaysOfWeek This) { System.Diagnostics.Debug.WriteLine($"From {This} to {DaysOfWeek.Monday} {This.NumberOfDaysUntil(DaysOfWeek.Monday)}"); System.Diagnostics.Debug.WriteLine($"From {This} to {DaysOfWeek.Tuesday} {This.NumberOfDaysUntil(DaysOfWeek.Tuesday)}"); System.Diagnostics.Debug.WriteLine($"From {This} to {DaysOfWeek.Wednesday} {This.NumberOfDaysUntil(DaysOfWeek.Wednesday)}"); System.Diagnostics.Debug.WriteLine($"From {This} to {DaysOfWeek.Thursday} {This.NumberOfDaysUntil(DaysOfWeek.Thursday)}"); System.Diagnostics.Debug.WriteLine($"From {This} to {DaysOfWeek.Friday} {This.NumberOfDaysUntil(DaysOfWeek.Friday)}"); System.Diagnostics.Debug.WriteLine($"From {This} to {DaysOfWeek.Saturday} {This.NumberOfDaysUntil(DaysOfWeek.Saturday)}"); System.Diagnostics.Debug.WriteLine($"From {This} to {DaysOfWeek.Sunday} {This.NumberOfDaysUntil(DaysOfWeek.Sunday)}"); }
public void Init() { _daysOfWeek = new DaysOfWeek { DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Thursday, DayOfWeek.Wednesday }; }
private DateTime GetDayDateByDisplayedSemester(int weekNumber, DaysOfWeek freeDay) { var weeksDifference = TimeSpan.FromTicks(new TimeSpan(7, 0, 0, 0).Ticks *(weekNumber - 1)); var dayDifference = new TimeSpan( (int)Enum.Parse(typeof(DaysOfWeek), _displayedSemester.StartDate.DayOfWeek.ToString()) - (int)freeDay, 0, 0, 0); return(_displayedSemester.StartDate + weeksDifference - dayDifference); }
static void Main(string[] args) { DaysOfWeek myDays = DaysOfWeek.Mon; Console.WriteLine(myDays); Console.WriteLine((int)myDays); Console.WriteLine((DaysOfWeek)1); Console.Read(); }
/// <summary> /// Returns a value indicating whether the provided DaysOfWeek value is applicable today. /// </summary> public static bool IsToday(DaysOfWeek days, DateTimeOffset currentTime) { // special handling for Night Owl so that its schedule is visible after midnight // i.e., if it's 2AM on Sunday, we still consider "today" to be Saturday. var time = (days == DaysOfWeek.NightOwl) ? currentTime.AddHours(-4) : currentTime; return((ToDaysOfWeek(time.DayOfWeek) & days) != DaysOfWeek.None); }
/// <summary> /// Returns a value indicating whether the provided DaysOfWeek value is applicable today. /// </summary> public static bool IsToday(DaysOfWeek days, DateTimeOffset currentTime) { // special handling for Night Owl so that its schedule is visible after midnight // i.e., if it's 2AM on Sunday, we still consider "today" to be Saturday. var time = (days == DaysOfWeek.NightOwl) ? currentTime.AddHours(-4) : currentTime; return (ToDaysOfWeek(time.DayOfWeek) & days) != DaysOfWeek.None; }
public ISet <DayOfWeek> Convert(DaysOfWeek value) { HashSet <DayOfWeek> result = new HashSet <DayOfWeek>(); foreach (Tuple <DaysOfWeek, DayOfWeek> tuple in DayOfWeekConverter.MappingTuples) { DayOfWeekConverter.AddDayToSetIfPresent(value, tuple.Item1, tuple.Item2, result); } return(result); }
public YearlyThRecurrencePattern(DaysOfWeek daysOfWeek, RecurrenceOrderType order, int month, bool isLeapMonth, int recurrenceInterval, CalendarType calendarType) { EnumValidator.ThrowIfInvalid <CalendarType>(calendarType); this.Month = month; this.DaysOfWeek = daysOfWeek; this.Order = order; this.isLeapMonth = isLeapMonth; this.calendarType = calendarType; base.RecurrenceInterval = recurrenceInterval; }
public RecurrenceDayOfWeek?Contains(string dayOfWeek) { RecurrenceDayOfWeek day; if (Enum.TryParse(dayOfWeek, out day) && DaysOfWeek.Contains(day)) { return(day); } return(null); }
public static bool AllSelected(this DaysOfWeek This) { return(This.HasFlag(DaysOfWeek.Monday) && This.HasFlag(DaysOfWeek.Tuesday) && This.HasFlag(DaysOfWeek.Wednesday) && This.HasFlag(DaysOfWeek.Thursday) && This.HasFlag(DaysOfWeek.Friday) && This.HasFlag(DaysOfWeek.Saturday) && This.HasFlag(DaysOfWeek.Sunday)); }
private async Task Save() { if (!string.IsNullOrEmpty(Name)) { Name = Name.TrimStart().TrimEnd(); } if (!string.IsNullOrEmpty(WakeUpText)) { WakeUpText = WakeUpText.TrimStart().TrimEnd(); } if (!string.IsNullOrEmpty(PackageName)) { PackageName = PackageName.TrimStart().TrimEnd(); } Alarm.TimeOffset = new DateTime(Date.Year, Date.Month, Date.Day, Time.Hours, Time.Minutes, 0); if (string.IsNullOrEmpty(Name)) { await Application.Current.MainPage.DisplayAlert("", AppResources.ForgotAlarmName, AppResources.OK); } else if (Alarm.TimeOffset.Subtract(DateTime.Now).Ticks < 0 && !DaysOfWeek.GetHasADayBeenSelected(Alarm.Days)) { await Application.Current.MainPage.DisplayAlert("", AppResources.SetTimePast, AppResources.OK); } else if (string.IsNullOrEmpty(WakeUpText) && Alarm.HasWakeUpText) { await Application.Current.MainPage.DisplayAlert("", AppResources.ForgotWordsThatWakeMeUp, AppResources.OK); } else if (string.IsNullOrEmpty(PackageName) && Alarm.IsLinkOtherApp) { await Application.Current.MainPage.DisplayAlert("", AppResources.ForgotLinkOtherApps, AppResources.OK); } else { if (!Alarm.IsActive) { Alarm.ChangeIsActive(Alarm, true); } Alarm.IsLaterAlarm = false; Alarm.IsGoOffPreAlarm = false; var id = Service.SaveAlarm(Alarm); if (Preferences.Get("MaxAlarmId", 3) < id) { Preferences.Set("MaxAlarmId", id); } await ClosePopup(); var diffString = CreateDateString.CreateTimeRemainingString(Alarm.NextAlarmTime); DependencyService.Get <IToastService>().Show(diffString); } }
/// <summary>Gets a value indicating if the specified <see cref="DayOfWeek"/> value is contained in the specified <see cref="DaysOfWeek"/> value.</summary> /// <param name="days">The <see cref="DaysOfWeek"/> value to check if <paramref name="value"/> is contained.</param> /// <param name="value">The <see cref="DayOfWeek"/> value to check if <paramref name="days"/> contains.</param> /// <returns>A value indicating if <paramref name="value"/> is included in <paramref name="days"/>.</returns> public static bool ContainsDayOfWeek(this DaysOfWeek days, DayOfWeek value) { // value is converted to a DaysOfWeek value by the following formula: // 2 ^ x // Where x is the integer value of of the DayOfWeek value (where 0 = Sun, 1 = Mon, 2 = Tues, 3 = Wed, etc) // This will result in 1 = Sun, 2 = Mon, 4 = Tues, 8 = Wed, etc. int day = (int)Math.Pow(2D, (double)value); return((day & (int)days) == day); }
public void Test() { DaysOfWeek mondayAndWendnesday = DaysOfWeek.Monday | DaysOfWeek.Wednesday; DaysOfWeek dow; Enum.TryParse <DaysOfWeek>("5", out dow); Console.WriteLine(dow); Console.WriteLine(mondayAndWendnesday); }
protected CronExpression(DaySeqNumber dayNumber, DaysOfWeek days, int monthInverval, int startHour, int startMinute, CronExpressionType expressionType) { _dayNumber = (int)dayNumber; _days = days; _interval = monthInverval; _startHour = startHour; _startMinute = startMinute; _expressionType = expressionType; BuildCronExpression(); }
private StorageWorkingHours(ExTimeZone timeZone, DaysOfWeek daysOfWeek, int startTimeInMinutes, int endTimeInMinutes) { if (timeZone == null) { throw new ArgumentException("timeZone"); } this.TimeZone = timeZone; this.daysOfWeek = daysOfWeek; this.startTimeInMinutes = startTimeInMinutes; this.endTimeInMinutes = endTimeInMinutes; }
public TimeSpanRuleInfo(TimeSpan dayTimeFrom, TimeSpan dayTimeTo, DaysOfWeek daysOfWeek, IEnumerable<DateTime> dateTimes = null) { DayTimeFrom = dayTimeFrom; DayTimeTo = dayTimeTo; DaysOfWeek = daysOfWeek; DateTimes = dateTimes; Validate(); }
static void Main(string[] args) { DaysOfWeek days = new DaysOfWeek(); foreach (string day in days) { Console.Write(day + " "); } Console.ReadLine(); }
protected CronExpression(DaySeqNumber dayNumber, DaysOfWeek days, Months month, int startHour, int startMinute, CronExpressionType expressionType) { _dayNumber = (int)dayNumber; _days = days; _month = month; _startHour = startHour; _startMinute = startMinute; _expressionType = expressionType; BuildCronExpression(); }
static void Main(string[] args) { DaysOfWeek today = DaysOfWeek.Monday; if (today == DaysOfWeek.Monday) { Console.WriteLine("CS 155: C#"); } Console.ReadKey(); }
static void Main(string[] args) { DaysOfWeek[] workdays = new DaysOfWeek[3] { DaysOfWeek.Monday, DaysOfWeek.Wednesday, DaysOfWeek.Saturday }; int hours = 0; foreach (DaysOfWeek workday in workdays) { hours = hours + GetHours(workday); } Console.WriteLine("You work {0} hours a week.", hours); }
public void EqualsEqTest() { var eq = new DaysOfWeek { DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Thursday, DayOfWeek.Wednesday }; Assert.AreEqual(_daysOfWeek, eq); Assert.IsTrue(_daysOfWeek.Equals(eq)); Assert.IsTrue(eq.Equals(_daysOfWeek)); Assert.IsTrue(_daysOfWeek == eq); Assert.IsTrue(eq == _daysOfWeek); }
public void EqualsNotEq2Test() { var eq = new DaysOfWeek { DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Thursday, DayOfWeek.Saturday }; Assert.AreNotEqual(_daysOfWeek, eq); Assert.IsFalse(_daysOfWeek.Equals(eq)); Assert.IsFalse(eq.Equals(_daysOfWeek)); Assert.IsFalse(_daysOfWeek == eq); Assert.IsFalse(eq == _daysOfWeek); }
public void DeserializeTest() { var timeSpanMin = new TimeSpan(5000); var timeSpanMax = new TimeSpan(50000); var daysOfWeek = new DaysOfWeek(DayOfWeek.Monday, DayOfWeek.Thursday); var dateTimes = new[] {new DateTime(100)}; _mockTimeSpanDeserializer.Setup(x => x.Deserialize("ts1")).Returns(timeSpanMin).Verifiable(); _mockTimeSpanDeserializer.Setup(x => x.Deserialize("ts2")).Returns(timeSpanMax).Verifiable(); _mockDaysOfWeekDeserializer.Setup(x => x.Deserialize("days")).Returns(daysOfWeek).Verifiable(); _mockDateTimesDeserializer.Setup(x => x.Deserialize("dates")).Returns(dateTimes).Verifiable(); const string str = "ts1\x001Ets2\x001Edays\x001Edates"; var actual = _timeSpanRuleInfoStringDeserializer.Deserialize(str); Assert.AreEqual(new TimeSpanRuleInfo(timeSpanMin, timeSpanMax, daysOfWeek, dateTimes), actual); _mockRepository.VerifyAll(); }
public static int GetHours(DaysOfWeek workday) { switch (workday) { case DaysOfWeek.Sunday: return 0; case DaysOfWeek.Monday: return 8; case DaysOfWeek.Tuesday: return 8; case DaysOfWeek.Wednesday: return 8; case DaysOfWeek.Thursday: return 8; case DaysOfWeek.Friday: return 8; case DaysOfWeek.Saturday: return 4; default: return 0; } }
public static string ToCronRepresentationSingle(DaysOfWeek day) { switch (day) { case DaysOfWeek.Monday: return "MON"; case DaysOfWeek.Tuesday: return "TUE"; case DaysOfWeek.Wednesday: return "WED"; case DaysOfWeek.Thursday: return "THU"; case DaysOfWeek.Friday: return "FRI"; case DaysOfWeek.Saturday: return "SAT"; case DaysOfWeek.Sunday: return "SUN"; default: throw new ArgumentException(); } }
private static extern Int32 _SetAutoDiscardWeekdays(string securityToken, DaysOfWeek newWeekdays);
/// <summary> /// Defines valid weekdays for an auto discard of a given fixed volume /// </summary> /// <param name="securityToken">Security token</param> /// <param name="deviceName">Device name of the volume</param> /// <param name="newWeekdays">Set of weekdays</param> /// <exception cref="Exception">if call was not successfull.</exception> public static void SetFixedVolumeAutoDiscardWeekdays(string securityToken, string deviceName, DaysOfWeek newWeekdays) { if (_SetFixedVolumeAutoDiscardWeekdays(securityToken, deviceName, newWeekdays) != 0) { throw new Exception(); } }
protected virtual void SelectDays(DaysOfWeek days) { if (days == DaysOfWeek.None) { this.Days.UncheckAll(); return; } foreach (var item in this.Days.Items) { var isSelected = false; if (Enum.IsDefined(typeof (DaysOfWeek), item.Value)) { var itemValue = (DaysOfWeek)Enum.Parse(typeof (DaysOfWeek), item.Value); isSelected = ((days & itemValue) == itemValue); } item.Checked = isSelected; } }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { _target ^= (DaysOfWeek)parameter; return _target; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var mask = (DaysOfWeek)parameter; _target = (DaysOfWeek)value; return ((mask & _target) != 0); }
/// <summary> /// This can be used to explicitly convert a <see cref="DaysOfWeek"/> value to a <see cref="System.DayOfWeek"/> /// value. /// </summary> /// <param name="days">The <c>DaysOfWeek</c> value to convert</param> /// <returns>Returns the <c>DaysOfWeek</c> value as a <c>DayOfWeek</c> value. If the <c>DaysOfWeek</c> /// value is a combination of days, only the first day of the week found is returned. If it is set to /// <c>None</c>, it returns Sunday.</returns> public static DayOfWeek ToDayOfWeek(DaysOfWeek days) { DayOfWeek d; if((days & DaysOfWeek.Sunday) != 0) d = DayOfWeek.Sunday; else if((days & DaysOfWeek.Monday) != 0) d = DayOfWeek.Monday; else if((days & DaysOfWeek.Tuesday) != 0) d = DayOfWeek.Tuesday; else if((days & DaysOfWeek.Wednesday) != 0) d = DayOfWeek.Wednesday; else if((days & DaysOfWeek.Thursday) != 0) d = DayOfWeek.Thursday; else if((days & DaysOfWeek.Friday) != 0) d = DayOfWeek.Friday; else if((days & DaysOfWeek.Saturday) != 0) d = DayOfWeek.Saturday; else d = DayOfWeek.Sunday; // Was set to None return d; }
/// <summary> /// This method is used to calculate the date on which a specific occurrence of any of a set of days /// occurs (for example, the 4th weekday in November or the last weekend day in January). /// </summary> /// <param name="year">The year in which the day occurs</param> /// <param name="month">The month in which the day occurs</param> /// <param name="occur">The occurrence of the day of the week on which the day falls</param> /// <param name="days">The day(s) of the week on which the day can occurs</param> /// <param name="offset">The number of days before or after the calculated date on which the day falls</param> /// <returns>Returns a <see cref="DateTime" /> object that represents the date calculated from the /// settings.</returns> /// <remarks><para>This method is intended for use in finding an occurrence of any one of a set of days /// of the week and is normally used with the <see cref="DaysOfWeek.Weekdays"/> or /// <see cref="DaysOfWeek.Weekends"/> day of week value. However, the days of week parameter can be any /// valid combination of days including an individual day of the week.</para> /// /// <para>Use a positive value for the <c>nOffset</c> parameter for a number of days after the calculated /// date or a negative number for a number of days before the calculated date.</para> /// /// <para>Normally, this value will be zero so that the calculated date is the actual date returned. /// However, in cases where a date is calculated in terms of the number of days before or after a given /// date, this can be set to the offset to adjust the calculated date. Note that if used, the date /// returned may not be on one of the days of the week specified to calculate the original unadjusted /// date.</para></remarks> /// <example> /// <code language="cs"> /// // Returns 01/06/2004 (fourth weekday in Jan 2004) /// dtFourthWeekday = DateUtils.CalculateOccurrenceDate(2004, 1, /// DayOccurrence.Fourth, DaysOfWeek.Weekdays, 0); /// /// // Returns 01/08/2004 (fourth weekday plus 2 days) /// dtPlusTwo = DateUtils.CalculateOccurrenceDate(2004, 1, /// DayOccurrence.Fourth, DaysOfWeek.Weekdays, 2); /// </code> /// <code language="vbnet"> /// ' Returns 01/06/2004 (fourth weekday in Jan 2004) /// dtFourthWeekday = DateUtils.CalculateOccurrenceDate(2004, 1, /// DayOccurrence.Fourth, DaysOfWeek.Weekdays, 0) /// /// ' Returns 01/08/2004 (fourth weekday plus 2 days) /// dtPlusTwo = DateUtils.CalculateOccurrenceDate(2004, 1, /// DayOccurrence.Fourth, DaysOfWeek.Weekdays, 2) /// </code> /// </example> /// <exception cref="ArgumentException">This is thrown if <c>None</c> is passed for the <c>DayOccurrence</c> /// parameter.</exception> public static DateTime CalculateOccurrenceDate(int year, int month, DayOccurrence occur, DaysOfWeek days, int offset) { DateTime dtDate; int count = 0, occurrence = (int)occur; if(occur == DayOccurrence.None) throw new ArgumentException(LR.GetString("ExDUOccurIsNone"), "occur"); // Calculating a specific occurrence or the last one? if(occur != DayOccurrence.Last) { dtDate = new DateTime(year, month, 1); while(count != occurrence) { switch(dtDate.DayOfWeek) { case DayOfWeek.Sunday: if((days & DaysOfWeek.Sunday) != 0) count++; break; case DayOfWeek.Monday: if((days & DaysOfWeek.Monday) != 0) count++; break; case DayOfWeek.Tuesday: if((days & DaysOfWeek.Tuesday) != 0) count++; break; case DayOfWeek.Wednesday: if((days & DaysOfWeek.Wednesday) != 0) count++; break; case DayOfWeek.Thursday: if((days & DaysOfWeek.Thursday) != 0) count++; break; case DayOfWeek.Friday: if((days & DaysOfWeek.Friday) != 0) count++; break; case DayOfWeek.Saturday: if((days & DaysOfWeek.Saturday) != 0) count++; break; } if(count != occurrence) dtDate = dtDate.AddDays(1); } } else { // Find last occurrence count++; dtDate = new DateTime(year, month, DateTime.DaysInMonth(year, month)); while(count != 0) { switch(dtDate.DayOfWeek) { case DayOfWeek.Sunday: if((days & DaysOfWeek.Sunday) != 0) count--; break; case DayOfWeek.Monday: if((days & DaysOfWeek.Monday) != 0) count--; break; case DayOfWeek.Tuesday: if((days & DaysOfWeek.Tuesday) != 0) count--; break; case DayOfWeek.Wednesday: if((days & DaysOfWeek.Wednesday) != 0) count--; break; case DayOfWeek.Thursday: if((days & DaysOfWeek.Thursday) != 0) count--; break; case DayOfWeek.Friday: if((days & DaysOfWeek.Friday) != 0) count--; break; case DayOfWeek.Saturday: if((days & DaysOfWeek.Saturday) != 0) count--; break; } if(count != 0) dtDate = dtDate.AddDays(-1); } } // Return the date plus any additional offset return dtDate.AddDays(offset); }
private static extern Int32 _SetFixedVolumeAutoDiscardWeekdays(string securityToken, string deviceName, DaysOfWeek newWeekdays);
public bool SetDayOfWeek(DaysOfWeek iDay) { return Imports.World.World_SetDayOfWeek((int)iDay); }
/// <summary> /// Initialize a yearly recurrence pattern that occurs on a specific occurrence of a day of the week in /// the specified month at the specified yearly interval (i.e. the last Sunday in September every year). /// </summary> /// <param name="occur">The occurrence of the day of the week on which to occur</param> /// <param name="daysOfWeek">The day of the week on which to occur</param> /// <param name="month">The month in which to occur.</param> /// <param name="recurInterval">The interval between occurrences in years</param> /// <remarks>This is a convenience method that mimics the yearly recurrence pattern in Microsoft Outlook. /// When called, it sets up the recurrence for a yearly pattern that recurs at the specified interval on /// the specified occurrence of the days of the week. All rule parts are cleared prior to setting the /// monthly options but other parameters such as the start date are left alone.</remarks> /// <exception cref="ArgumentOutOfRangeException">An exception is thrown if the month is not between 1 /// and 12.</exception> /// <include file='DateExamples.xml' path='Examples/Recurrence/HelpEx[@name="Ex8"]/*' /> public void RecurYearly(DayOccurrence occur, DaysOfWeek daysOfWeek, int month, int recurInterval) { // Month should be valid if(month < 1 || month > 12) throw new ArgumentOutOfRangeException("month", month, LR.GetString("ExRecurBadMonth")); this.Frequency = RecurFrequency.Yearly; this.Interval = recurInterval; byMonth.Clear(); byWeekNo.Clear(); byYearDay.Clear(); byMonthDay.Clear(); byHour.Clear(); byMinute.Clear(); bySecond.Clear(); bySetPos.Clear(); byDay.Clear(); customProps.Clear(); byMonth.Add(month); // Set day(s) if((daysOfWeek & DaysOfWeek.Sunday) != 0) byDay.Add(new DayInstance(DayOfWeek.Sunday)); if((daysOfWeek & DaysOfWeek.Monday) != 0) byDay.Add(new DayInstance(DayOfWeek.Monday)); if((daysOfWeek & DaysOfWeek.Tuesday) != 0) byDay.Add(new DayInstance(DayOfWeek.Tuesday)); if((daysOfWeek & DaysOfWeek.Wednesday) != 0) byDay.Add(new DayInstance(DayOfWeek.Wednesday)); if((daysOfWeek & DaysOfWeek.Thursday) != 0) byDay.Add(new DayInstance(DayOfWeek.Thursday)); if((daysOfWeek & DaysOfWeek.Friday) != 0) byDay.Add(new DayInstance(DayOfWeek.Friday)); if((daysOfWeek & DaysOfWeek.Saturday) != 0) byDay.Add(new DayInstance(DayOfWeek.Saturday)); // If only one day was added, set its instance as it will be more efficient than using BYSETPOS if(byDay.Count == 1) { if(occur == DayOccurrence.Last) byDay[0].Instance = -1; else byDay[0].Instance = (int)occur; } else if(occur == DayOccurrence.Last) bySetPos.Add(-1); else bySetPos.Add((int)occur); }
/// <summary> /// Initialize a monthly recurrence pattern that occurs on a specific occurrence of a day of the week at /// the specified monthly interval (i.e. the 4th Tuesday every two months). /// </summary> /// <param name="occur">The occurrence of the day of the week on which to occur.</param> /// <param name="daysOfWeek">The days of the week on which to occur. This may be an individual week day /// or any combination of week days.</param> /// <param name="recurInterval">The interval between occurrences in months.</param> /// <remarks>This is a convenience method that mimics the monthly recurrence pattern in Microsoft /// Outlook. When called, it sets up the recurrence for a monthly pattern that recurs at the specified /// interval on the specified occurrence of the days of the week. All rule parts are cleared prior to /// setting the monthly options but other parameters such as the start date are left alone.</remarks> /// <include file='DateExamples.xml' path='Examples/Recurrence/HelpEx[@name="Ex6"]/*' /> public void RecurMonthly(DayOccurrence occur, DaysOfWeek daysOfWeek, int recurInterval) { this.Frequency = RecurFrequency.Monthly; this.Interval = recurInterval; byMonth.Clear(); byWeekNo.Clear(); byYearDay.Clear(); byMonthDay.Clear(); byHour.Clear(); byMinute.Clear(); bySecond.Clear(); bySetPos.Clear(); byDay.Clear(); customProps.Clear(); // Set day(s) if((daysOfWeek & DaysOfWeek.Sunday) != 0) byDay.Add(new DayInstance(DayOfWeek.Sunday)); if((daysOfWeek & DaysOfWeek.Monday) != 0) byDay.Add(new DayInstance(DayOfWeek.Monday)); if((daysOfWeek & DaysOfWeek.Tuesday) != 0) byDay.Add(new DayInstance(DayOfWeek.Tuesday)); if((daysOfWeek & DaysOfWeek.Wednesday) != 0) byDay.Add(new DayInstance(DayOfWeek.Wednesday)); if((daysOfWeek & DaysOfWeek.Thursday) != 0) byDay.Add(new DayInstance(DayOfWeek.Thursday)); if((daysOfWeek & DaysOfWeek.Friday) != 0) byDay.Add(new DayInstance(DayOfWeek.Friday)); if((daysOfWeek & DaysOfWeek.Saturday) != 0) byDay.Add(new DayInstance(DayOfWeek.Saturday)); // If only one day was added, set its instance as it will be more efficient than using BYSETPOS if(byDay.Count == 1) { if(occur == DayOccurrence.Last) byDay[0].Instance = -1; else byDay[0].Instance = (int)occur; } else if(occur == DayOccurrence.Last) bySetPos.Add(-1); else bySetPos.Add((int)occur); }
/// <summary> /// Initialize a weekly recurrence pattern /// </summary> /// <param name="recurInterval">The interval between occurrences in weeks</param> /// <param name="daysOfWeek">The days of the week on which the instances should occur</param> /// <remarks>This is a convenience method that mimics the weekly recurrence pattern in Microsoft Outlook. /// When called, it sets up the recurrence for a weekly pattern that recurs at the specified interval on /// the specified days of the week. All rule parts are cleared prior to setting the weekly options but /// other parameters such as the start date are left alone.</remarks> /// <seealso cref="DaysOfWeek"/> /// <include file='DateExamples.xml' path='Examples/Recurrence/HelpEx[@name="Ex7"]/*' /> public void RecurWeekly(int recurInterval, DaysOfWeek daysOfWeek) { this.Frequency = RecurFrequency.Weekly; this.Interval = recurInterval; byMonth.Clear(); byWeekNo.Clear(); byYearDay.Clear(); byMonthDay.Clear(); byHour.Clear(); byMinute.Clear(); bySecond.Clear(); bySetPos.Clear(); byDay.Clear(); customProps.Clear(); // Set day(s) if((daysOfWeek & DaysOfWeek.Sunday) != 0) byDay.Add(new DayInstance(DayOfWeek.Sunday)); if((daysOfWeek & DaysOfWeek.Monday) != 0) byDay.Add(new DayInstance(DayOfWeek.Monday)); if((daysOfWeek & DaysOfWeek.Tuesday) != 0) byDay.Add(new DayInstance(DayOfWeek.Tuesday)); if((daysOfWeek & DaysOfWeek.Wednesday) != 0) byDay.Add(new DayInstance(DayOfWeek.Wednesday)); if((daysOfWeek & DaysOfWeek.Thursday) != 0) byDay.Add(new DayInstance(DayOfWeek.Thursday)); if((daysOfWeek & DaysOfWeek.Friday) != 0) byDay.Add(new DayInstance(DayOfWeek.Friday)); if((daysOfWeek & DaysOfWeek.Saturday) != 0) byDay.Add(new DayInstance(DayOfWeek.Saturday)); }
/// <summary> /// Defines valid weekdays for the global auto discard of fixed volumes. /// </summary> /// <param name="securityToken">Security token</param> /// <param name="newWeekdays">Set of weekdays</param> /// <exception cref="Exception">if call was not successfull.</exception> public static void SetAutoDiscardWeekdays(string securityToken, DaysOfWeek newWeekdays) { if (_SetAutoDiscardWeekdays(securityToken, newWeekdays) != 0) { throw new Exception(); } }
public DosageDetail CreateDosageDetail(TestResult testResult, DaysOfWeek day, double value) { return null; //WCCMainRepository.CreateDosageDetail(testResult, day, value); }