/// <summary> /// Determines the number of days from one DayOfWeek till the next. /// </summary> /// <param name="self">the starting DayOfWeek</param> /// <param name="next">The ending DayOfWeek</param> /// <returns>the number of days from <paramref name="self"/> to <paramref name="next"/></returns> /// <exception cref="ArgumentOutOfRangeException">If either DayOfWeek is not /// <see cref="DayOfWeekExtensions.InRange"/></exception> /// <example> /// Debug.Assert(DayOfWeek.Monday.DaysTill(DayOfWeek.Tuesday) == 1); /// </example> public static int DaysTill(this DayOfWeek self, DayOfWeek next) { self.CheckRange(); next.CheckRange(); return DaysBetween((int)next, (int)self); }
/// <summary> /// Initializes a new instance of the <see cref="CalendarViewFormat"/> class. /// </summary> /// <param name="viewType">Type of the view.</param> /// <param name="showday">The showday.</param> /// <param name="weekStartDay">The week start day.</param> public CalendarViewFormat(CalendarViewType viewType, DateTime showday,DayOfWeek weekStartDay) { int index, w; switch (viewType) { case CalendarViewType.day: //日 StartDate = showday.Date; EndDate = showday.Date.AddHours(23).AddMinutes(59).AddSeconds(59); break; case CalendarViewType.week: // 周 index = weekStartDay.GetHashCode();//0 w = index - showday.DayOfWeek.GetHashCode();//0-1 if (w > 0) w = w - 7; StartDate = showday.AddDays(w).Date; EndDate = StartDate.AddDays(6).AddHours(23).AddMinutes(59).AddSeconds(59); break; case CalendarViewType.month: // 月 DateTime firstdate = new DateTime(showday.Year, showday.Month,1); index = weekStartDay.GetHashCode();//0 w = index - firstdate.DayOfWeek.GetHashCode();//0-1 if (w > 0){ w -= 7; } StartDate = firstdate.AddDays(w).Date; EndDate = StartDate.AddDays(34); if (EndDate.Year == showday.Year && EndDate.Month == showday.Month && EndDate.AddDays(1).Month == EndDate.Month) { EndDate = EndDate.AddDays(7); } EndDate.AddHours(23).AddMinutes(59).AddSeconds(59); break; } }
/// <summary> /// Adds a specified number of business <paramref name="days" /> to a <paramref name="dateTime" /> taking into account /// weekends and holidays /// </summary> /// <param name="dateTime">The DateTime to add the business days to</param> /// <param name="days">The number of business days to add</param> /// <param name="weekendDays"> /// The days of the week to consider as the weekend. These days of the week will be excluded when /// determining business days. /// </param> /// <param name="holidays">Holidays dates to exclude when determining business days</param> /// <returns>The new DateTime after adding the specified number of business <paramref name="days" /></returns> public static DateTime AddBusinessDays(DateTime dateTime, double days, DayOfWeek[] weekendDays, params DateTime[] holidays) { if (Abs(days) < TOLERANCE) return dateTime; var wholeDays = Truncate(days); var partDay = Abs(wholeDays) > TOLERANCE ? days%wholeDays : 0; var range = Abs(wholeDays); var direction = Sign(wholeDays); for (var wholeDay = 0; wholeDay < range; wholeDay++) { do dateTime = dateTime.AddDays(direction); while (IsOutsideBusinessDays(dateTime, weekendDays, holidays)); } if (IsOutsideBusinessDays(dateTime, weekendDays, holidays)) dateTime = dateTime.AddDays(direction); dateTime = dateTime.AddDays(partDay); while (IsOutsideBusinessDays(dateTime, weekendDays, holidays)) dateTime = dateTime.AddDays(direction); return dateTime; }
/// <summary> /// 获取星期。 /// </summary> /// <returns>星期一</returns> public string ToChinaWeek(DayOfWeek day) { if (day == DayOfWeek.Monday) { return "星期一"; } else if (day == DayOfWeek.Tuesday) { return "星期二"; } else if (day == DayOfWeek.Wednesday) { return "星期三"; } else if (day == DayOfWeek.Thursday) { return "星期四"; } else if (day == DayOfWeek.Friday) { return "星期五"; } else if (day == DayOfWeek.Saturday) { return "星期六"; } else if (day == DayOfWeek.Sunday) { return "星期天"; } return ""; }
public static uint DayToUint(DayOfWeek day) { for (int i = 0; i < days.Length; i++) if (days[i] == day) return (uint)i; return 0; }
/// <summary> /// Initializes a new instance of the <see cref="BusinessDay"/> class. /// </summary> /// <param name="dayOfWeek">The day of week this business day represents.</param> /// <param name="startTime">The start time of the business day.</param> /// <param name="endTime">The end time of the business day.</param> public BusinessDay(DayOfWeek dayOfWeek, TimeSpan startTime, TimeSpan endTime) { if (startTime.TotalDays >= 1) #if SILVERLIGHT throw new ArgumentOutOfRangeException("startTime", "The startTime argument must be less then one day."); #else throw new ArgumentOutOfRangeException("startTime", startTime, "The startTime argument must be less then one day."); #endif if (endTime.TotalDays > 1) #if SILVERLIGHT throw new ArgumentOutOfRangeException("endTime", "The endTime argument must be less then one day."); #else throw new ArgumentOutOfRangeException("endTime", endTime, "The endTime argument must be less then one day."); #endif if (endTime <= startTime) #if SILVERLIGHT throw new ArgumentOutOfRangeException("endTime", "The endTime argument must be greater then startTime."); #else throw new ArgumentOutOfRangeException("endTime", endTime, "The endTime argument must be greater then startTime."); #endif DayOfWeek = dayOfWeek; StartTime = startTime; EndTime = endTime; }
/// <summary> /// Determines the number of days since one DayOfWeek since the previous. /// </summary> /// <param name="self">the starting DayOfWeek</param> /// <param name="prev">The previous DayOfWeek</param> /// <returns>the number of days since <paramref name="self"/> to <paramref name="prev"/></returns> /// <exception cref="ArgumentOutOfRangeException">If either DayOfWeek is not /// <see cref="DayOfWeekExtensions.InRange"/></exception> /// <example> /// Debug.Assert(DayOfWeek.Tuesday.DaysSince(DayOfWeek.Monday) == 1); /// </example> public static int DaysSince(this DayOfWeek self, DayOfWeek prev) { self.CheckRange(); prev.CheckRange(); return DaysBetween((int)self, (int)prev); }
public TimelineModel this[DayOfWeek i] { get { return Days[(int)i]; } }
static string ImeDana(DayOfWeek danUTjednu) { switch (danUTjednu) { case DayOfWeek.Monday: return "ponedjeljak"; case DayOfWeek.Tuesday: return "utorak"; case DayOfWeek.Wednesday: return "srijeda"; case DayOfWeek.Thursday: return "četvrtak"; case DayOfWeek.Friday: return "petak"; case DayOfWeek.Saturday: return "subota"; case DayOfWeek.Sunday: return "nedjelja"; // Dopisati grane case za svaki dan u tjednu (DayOfWeek.Tuesday = Utorak, itd.) default: return "Neispravan dan u tjednu"; } }
public static bool TrueOnDayOfWeek(DayOfWeek dayOfWeek, string daysOfWeekGrid) { int index = DaysOfWeekGrid.IndexOfDayOfWeek(dayOfWeek); bool retValue = DaysOfWeekGrid.NOT_THIS_DAY != daysOfWeekGrid[index]; return retValue; }
/// <summary> /// Convert starting day of week from enum to number - passed to calendar jquery control. /// </summary> /// <param name="name">Day name</param> protected int ConvertFirstDayToNumber(DayOfWeek name) { switch (name) { case DayOfWeek.Monday: return 1; case DayOfWeek.Tuesday: return 2; case DayOfWeek.Wednesday: return 3; case DayOfWeek.Thursday: return 4; case DayOfWeek.Friday: return 5; case DayOfWeek.Saturday: return 6; default: return 0; } }
public static int GetDayNumberOnAWeek(DayOfWeek dayOfWeek) { switch(dayOfWeek) { case DayOfWeek.Sunday: return 7; break; case DayOfWeek.Monday: return 1; break; case DayOfWeek.Tuesday: return 2; break; case DayOfWeek.Wednesday: return 3; break; case DayOfWeek.Thursday: return 4; break; case DayOfWeek.Friday: return 5; break; case DayOfWeek.Saturday: return 6; break; default: throw new ArgumentOutOfRangeException("dayOfWeek"); } }
public static int GetDaysDiff(DayOfWeek from, DayOfWeek to) { int fromNumber = from == DayOfWeek.Sunday ? 7 : Convert.ToInt32(from); int toNumber = to == DayOfWeek.Sunday ? 7 : Convert.ToInt32(to); int toReturn = toNumber - fromNumber; return toReturn; }
public static DateTime GetDateFromDynamic(DateMagnitude magnitude, int offset, bool isEndDate, DateTimeOffset todaysDate, DayOfWeek weekStart, TimeZoneInfo timeZone) { var localToday = TimeZoneInfo.ConvertTime(todaysDate, timeZone); DateTimeOffset result; if (isEndDate) offset++; switch (magnitude) { case DateMagnitude.BusinessDay: var offsetMagn = Math.Abs(offset); var offsetSign = Math.Sign(offset); var i = 0; result = localToday; while (i < offsetMagn) { result = result.AddDays(offsetSign); if (result.DayOfWeek != DayOfWeek.Sunday && result.DayOfWeek != DayOfWeek.Saturday) i++; } break; case DateMagnitude.Week: result = GetWeekStart(todaysDate, weekStart).AddDays(offset * 7); break; case DateMagnitude.Month: result = new DateTimeOffset(todaysDate.Year, todaysDate.Month, 1, 0, 0, 0, localToday.Offset).AddMonths(offset); break; case DateMagnitude.Quarter: switch (todaysDate.Month) { case 1: case 2: case 3: result = new DateTimeOffset(todaysDate.Year, 1, 1, 0, 0, 0, localToday.Offset).AddMonths(offset * 3); break; case 4: case 5: case 6: result = new DateTimeOffset(todaysDate.Year, 4, 1, 0, 0, 0, localToday.Offset).AddMonths(offset * 3); break; case 7: case 8: case 9: result = new DateTimeOffset(todaysDate.Year, 7, 1, 0, 0, 0, localToday.Offset).AddMonths(offset * 3); break; default: result = new DateTimeOffset(todaysDate.Year, 10, 1, 0, 0, 0, localToday.Offset).AddMonths(offset * 3); break; } break; case DateMagnitude.Year: result = new DateTimeOffset(todaysDate.Year, 1, 1, 0, 0, 0, localToday.Offset).AddYears(offset * 3); break; default: result = todaysDate.AddDays(offset); break; } if (isEndDate) return result.Date.AddMilliseconds(-1); return result.Date; }
/// <summary> /// Returns the first day of week with in the month. /// </summary> /// <param name="obj">DateTime Base, from where the calculation will be preformed.</param> /// <param name="dow">What day of week to find the first one of in the month.</param> /// <returns>Returns DateTime object that represents the first day of week with in the month.</returns> public static DateTime FirstDayOfWeekInMonth(this DateTime obj, DayOfWeek dow) { var firstDay = new DateTime(obj.Year, obj.Month, 1); int diff = firstDay.DayOfWeek - dow; if (diff > 0) diff -= 7; return firstDay.AddDays(diff * -1); }
public bool IsWorkingDay(DayOfWeek dayOfWeek) { if (dayOfWeek == DayOfWeek.Friday || dayOfWeek == DayOfWeek.Saturday) { return false; } return true; }
public static DateTime GetEndOfWeek(DateTime date, DayOfWeek lastDayOfWeek) { while (date.DayOfWeek != lastDayOfWeek) date = date.AddDays(1); return (date); }
public static DayOfWeek GetNextDay(DayOfWeek currentDay) { if ((int)currentDay == 6) return (DayOfWeek)0; return (DayOfWeek)(currentDay + 1); }
/// <summary> /// Gets the last. /// </summary> /// <param name="input"> The date/ time.</param> /// <param name="dayOfWeek">The day of week.</param> /// <returns>DateTime.</returns> public static DateTime GetLast(this DateTime input, DayOfWeek dayOfWeek) { Contract.Requires<ArgumentOutOfRangeException>(Enum.IsDefined(typeof(DayOfWeek), input)); var daysToSubtract = input.DayOfWeek > dayOfWeek ? input.DayOfWeek - dayOfWeek : (7 - (int)dayOfWeek) + (int)input.DayOfWeek; return input.AddDays(daysToSubtract * -1); }
public static List<TimeSlot> GetListBoxRoomDayTimeSlot(ListBox listBox, DayOfWeek dayOfWeek) { uint startHour = 0; uint endHour = 0; uint previousHour = 0; List<TimeSlot> result = new List<TimeSlot>(); foreach (int selectedIndex in listBox.SelectedIndices) { uint hour = (uint) selectedIndex + 7; if (hour != previousHour + 1) // new Timeslot { if (startHour != 0) { result.Add(new TimeSlot(dayOfWeek, startHour, endHour)); } startHour = hour; } endHour = hour + 1; previousHour = hour; } if (startHour != 0) { result.Add(new TimeSlot(dayOfWeek, startHour, endHour)); } return result; }
/// <summary> /// Initializes a new instance of the <see cref="LocationWorkHour"/> class. /// </summary> /// <param name="dayOfWeek">The day of week.</param> /// <param name="workHourTimeRange">The work hour time range.</param> public LocationWorkHour(DayOfWeek dayOfWeek, TimeRange workHourTimeRange) { Check.IsNotNull(dayOfWeek, () => DayOfWeek); _dayOfWeek = dayOfWeek; _workHourTimeRange = workHourTimeRange; }
internal TimeCondition(ValueType valueType, CounterType counter, uint value, DayOfWeek dayOfWeek) { ValueType = valueType; CounterType = counter; Value = value; DayOfWeek = dayOfWeek; }
/// <summary> /// Creates a new range with the specified information /// </summary> /// <param name="day"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> public CalendarHighlightRange(DayOfWeek day, TimeSpan startTime, TimeSpan endTime) : this() { _dayOfWeek = day; _startTime = startTime; _endTime = endTime; }
public TimeSlot(DayOfWeek dayOfWeek, int p1, int p2) { // TODO: Complete member initialization this.dayOfWeek = dayOfWeek; this.from = p1; this.to = p2; }
public DayOfWeekAnnualReccurance(DayOfWeek dayOfWeek, WeekOfMonth week, Month month, bool substituteWeekend = true) : base(substituteWeekend) { DayOfWeek = dayOfWeek; Week = week; Month = month; }
internal AxisElement(GanttView view, XPathNavigator node) : base(view, node) { _scale = (ScaleLevel)Enum.Parse(typeof(ScaleLevel), Attributes[ScaleName].Value); _interval = int.Parse(Attributes[IntervalName].Value, CultureInfo.InvariantCulture); _format = Attributes[FormatName].Value; if(_scale == ScaleLevel.Week) _firstDay = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), Attributes[FirstDayName].Value); if (Attributes.ContainsKey(TitleTypeName)) { string titleTypeValue = Attributes[TitleTypeName].Value; if (!string.IsNullOrEmpty(titleTypeValue)) { _titleType = (TitleType)Enum.Parse(typeof(TitleType), titleTypeValue); } } if (Attributes.ContainsKey(WidthName)) { string widthValue = Attributes[WidthName].Value; if (!string.IsNullOrEmpty(widthValue)) { this.Width = int.Parse(widthValue, NumberStyles.Integer, CultureInfo.InvariantCulture); } } }
public MonthView() { SetStyle(ControlStyles.Opaque, true); DoubleBuffered = true; _dayNamesFormat = "ddd"; _monthTitleFormat = "MMMM yyyy"; _selectionMode = MonthViewSelection.Manual; _workWeekStart = DayOfWeek.Monday; _workWeekEnd = DayOfWeek.Friday; _weekStart = DayOfWeek.Sunday; _dayNamesVisible = true; _dayNamesLength = 2; _viewStart = DateTime.Now; _itemPadding = new Padding(2); _monthTitleColor = SystemColors.ActiveCaption; _monthTitleColorInactive = SystemColors.InactiveCaption; _monthTitleTextColor = SystemColors.ActiveCaptionText; _monthTitleTextColorInactive = SystemColors.InactiveCaptionText; _dayBackgroundColor = Color.Empty; _daySelectedBackgroundColor = SystemColors.Highlight; _dayTextColor = SystemColors.WindowText; _daySelectedTextColor = SystemColors.HighlightText; _arrowsColor = SystemColors.Window; _arrowsSelectedColor = Color.Gold; _dayGrayedText = SystemColors.GrayText; _todayBorderColor = Color.Maroon; UpdateMonthSize(); UpdateMonths(); }
/// <summary> /// Tries to get the day on which <paramref name="dayOfWeek" /> /// has occurred the <paramref name="ordinal" /> number of times in a given /// <paramref name="month" /> of a given <paramref name="year" />. If the /// <paramref name="dayOfWeek" /> does not occur <paramref name="ordinal" /> times then the /// day of the last occurrence will be returned. /// </summary> /// <param name="year"></param> /// <param name="month"></param> /// <param name="ordinal"></param> /// <param name="dayOfWeek"></param> /// <returns></returns> private static int GetDayOfOrdinalOrLastDayOfWeekOccurrenceInMonth(int year, int month, int ordinal, DayOfWeek dayOfWeek) { var testDateTime = new DateTime(year, month, 1); int dayOfWeekOccurrenceCount = 0; int dayOfLastCountedDayOfWeekOccurrence = 0; // within the bounds of a given month while (testDateTime.Month == month) { // every time we find DayOfWeek update the count and record the day it occurs on if (testDateTime.DayOfWeek == dayOfWeek) { dayOfWeekOccurrenceCount++; dayOfLastCountedDayOfWeekOccurrence = testDateTime.Day; } // if the DayOfWeek has occurred ordinal times we found a solution. if (dayOfWeekOccurrenceCount == ordinal) { return testDateTime.Day; } // otherwise keep iterating testDateTime = testDateTime.AddDays(1); } // if the dayOfWeekOccurrenceCount didn't reach the desired ordinal in this month // then fallback to the last occurrence return dayOfLastCountedDayOfWeekOccurrence; }
/// <summary> /// Finds the shift with the specified teams shift ID by searching all the cached shifts in /// the specified range of weeks. /// </summary> /// <param name="shiftId">The teams ID of the shift to search for.</param> /// <param name="teamId">The ID of the team containing the shift.</param> /// <param name="pastWeeks">The number of past weeks to search.</param> /// <param name="futureWeeks">The number of future weeks to search.</param> /// <param name="startDayOfWeek">The start day of the week for the team.</param> /// <param name="scheduleCacheService">The schedule cache service to use to load the schedules.</param> /// <param name="timeService">The time service to use to get the current times.</param> /// <returns></returns> internal static async Task <ShiftModel> FindShiftByTeamsShiftIdAsync(string shiftId, string teamId, int pastWeeks, int futureWeeks, DayOfWeek startDayOfWeek, IScheduleCacheService scheduleCacheService, ISystemTimeService timeService) { var cacheModels = await LoadSchedulesAsync(teamId, pastWeeks, futureWeeks, startDayOfWeek, scheduleCacheService, timeService).ConfigureAwait(false); return(FindShiftByTeamsShiftId(cacheModels, shiftId)); }
/// <summary> /// Finds the next date whose day of the week equals the specified day of the week. /// </summary> /// <param name="startDate"> /// The date to begin the search. /// </param> /// <param name="desiredDay"> /// The desired day of the week whose date will be returneed. /// </param> /// <returns> /// Next occurrence /// </returns> public static DateTime GetNextDateForDay(this DateTime startDate, DayOfWeek desiredDay) { return(startDate.AddDays(DaysToAdd(startDate.DayOfWeek, desiredDay))); }
private static bool IsWorkday(DayOfWeek dayOfWeek) { return(!(dayOfWeek == DayOfWeek.Saturday || dayOfWeek == DayOfWeek.Sunday)); }
/// <summary> /// Gets the first occurrence of the given day of the month in the given DateTime. /// </summary> /// <param name="date">The given DateTime.</param> /// <param name="day">The day to be found.</param> /// <returns>DateTime instance of the first occurrence of the given day.</returns> public static DateTime GetFirstDayOccurrenceOfTheMonth(this DateTime date, DayOfWeek day) { var firstDayOfMonth = date.GetFirstDayOfTheMonth(); return(firstDayOfMonth.DayOfWeek == day ? firstDayOfMonth : firstDayOfMonth.GetNextDay(day)); }
//public OpeningHours(IList<WorkDay> workDays) //{ // FillHours(); //} public void EditHoursOfDay(DayOfWeek day, List <TimeRange> hours) { this.WorkDays.Single(wd => wd.Day == day).Hours = hours; }
public NoInterface(DayOfWeek dayOfWeek) { this.DayOfWeek = dayOfWeek; this.Info = $"DEFAULT {nameof(Info)} for {dayOfWeek}"; }
public static DateTime LastDayOfWeek(this DateTime date, DayOfWeek startOfWeek) { var firstDayOfWeek = FirstDayOfWeek(date, startOfWeek); return(firstDayOfWeek.AddDays(6)); }
public bool IsWorkingDay(DayOfWeek self) { return(_config.RunAtWeekend || !(self == DayOfWeek.Saturday || self == DayOfWeek.Sunday)); }
public static DateTime StartOfWeek(this DateTime dt, DayOfWeek startOfWeek) { int diff = (7 + (dt.DayOfWeek - startOfWeek)) % 7; return(dt.AddDays(-1 * diff).Date); }
public static DateTime ToNextDayOfWeek(this DateTime current, DayOfWeek day, bool excludeToday = false) => current.AddDays(current.DaysTo(day, excludeToday));
public static string GetShortWeek(DayOfWeek day) { string[] days = new[] { "周日", "周一", "周二", "周三", "周四", "周五", "周六" }; return(days[(int)day]); }
/// <summary> /// Calculates the first date that occurs in a calendar /// week given the year, week-rule and which day of the /// week should be used as the first of the week. /// </summary> public static DateTime FirstDateOfWeek(this Calendar calendar, int year, int weekOfYear, CalendarWeekRule weekRule, DayOfWeek firstDayOfWeek) { // Source & credit: // http://stackoverflow.com/questions/662379/calculate-date-from-week-number/914943#914943 if (calendar == null) { throw new ArgumentNullException("calendar"); } var jan1 = new DateTime(year, 1, 1); var daysOffset = (int)firstDayOfWeek - (int)jan1.DayOfWeek; var firstMonday = jan1.AddDays(daysOffset); var firstWeek = calendar.GetWeekOfYear(jan1, weekRule, firstDayOfWeek); return(firstMonday.AddDays((weekOfYear - (firstWeek <= 1 ? 1 : 0)) * 7)); }
/// <summary> /// Gets the next occurence of the specified weekday within the current week using the specified culture. /// </summary> /// <param name = "date">The base date.</param> /// <param name = "weekday">The desired weekday.</param> /// <param name = "cultureInfo">The culture to determine the first weekday of a week.</param> /// <returns>The calculated date.</returns> /// <example> /// <code> /// var thisWeeksMonday = DateTime.Now.GetWeekday(DayOfWeek.Monday); /// </code> /// </example> public static DateTime GetWeeksWeekday(this DateTime date, DayOfWeek weekday, CultureInfo cultureInfo) { var firstDayOfWeek = date.GetFirstDayOfWeek(cultureInfo); return(firstDayOfWeek.GetNextWeekday(weekday)); }
public static string GetWeek(DayOfWeek day) { string[] days = new[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" }; return(days[(int)day]); }
public override bool isBusinessDay(Date date) { DayOfWeek w = date.DayOfWeek; int d = date.Day; Month m = (Month)date.Month; int y = date.Year; if (isWeekend(w) // New Year's Day || (d == 1 && m == Month.January) || (y == 2005 && d == 3 && m == Month.January) || (y == 2006 && (d == 2 || d == 3) && m == Month.January) || (y == 2007 && d <= 3 && m == Month.January) || (y == 2007 && d == 31 && m == Month.December) || (y == 2009 && d == 2 && m == Month.January) || (y == 2011 && d == 3 && m == Month.January) || (y == 2012 && (d == 2 || d == 3) && m == Month.January) // Chinese New Year || (y == 2004 && d >= 19 && d <= 28 && m == Month.January) || (y == 2005 && d >= 7 && d <= 15 && m == Month.February) || (y == 2006 && ((d >= 26 && m == Month.January) || (d <= 3 && m == Month.February))) || (y == 2007 && d >= 17 && d <= 25 && m == Month.February) || (y == 2008 && d >= 6 && d <= 12 && m == Month.February) || (y == 2009 && d >= 26 && d <= 30 && m == Month.January) || (y == 2010 && d >= 15 && d <= 19 && m == Month.January) || (y == 2011 && d >= 2 && d <= 8 && m == Month.February) || (y == 2012 && d >= 23 && d <= 28 && m == Month.January) // Ching Ming Festival || (y <= 2008 && d == 4 && m == Month.April) || (y == 2009 && d == 6 && m == Month.April) || (y == 2010 && d == 5 && m == Month.April) || (y == 2011 && d >= 3 && d <= 5 && m == Month.April) || (y == 2012 && d == 4 && m == Month.April) // Labor Day || (y <= 2007 && d >= 1 && d <= 7 && m == Month.May) || (y == 2008 && d >= 1 && d <= 2 && m == Month.May) || (y == 2009 && d == 1 && m == Month.May) || (y == 2010 && d == 3 && m == Month.May) || (y == 2011 && d == 2 && m == Month.May) || (y == 2012 && ((d == 30 && m == Month.April) || (d == 1 && m == Month.May))) // Tuen Ng Festival || (y <= 2008 && d == 9 && m == Month.June) || (y == 2009 && (d == 28 || d == 29) && m == Month.May) || (y == 2010 && d >= 14 && d <= 16 && m == Month.June) || (y == 2011 && d >= 4 && d <= 6 && m == Month.June) || (y == 2012 && d >= 22 && d <= 24 && m == Month.June) // Mid-Autumn Festival || (y <= 2008 && d == 15 && m == Month.September) || (y == 2010 && d >= 22 && d <= 24 && m == Month.September) || (y == 2011 && d >= 10 && d <= 12 && m == Month.September) || (y == 2012 && d == 30 && m == Month.September) // National Day || (y <= 2007 && d >= 1 && d <= 7 && m == Month.October) || (y == 2008 && ((d >= 29 && m == Month.September) || (d <= 3 && m == Month.October))) || (y == 2009 && d >= 1 && d <= 8 && m == Month.October) || (y == 2010 && d >= 1 && d <= 7 && m == Month.October) || (y == 2011 && d >= 1 && d <= 7 && m == Month.October) || (y == 2012 && d >= 1 && d <= 7 && m == Month.October) ) { return(false); } return(true); }
/// <summary> /// Gets the next occurence of the specified weekday within the current week using the current culture. /// </summary> /// <param name = "date">The base date.</param> /// <param name = "weekday">The desired weekday.</param> /// <returns>The calculated date.</returns> /// <example> /// <code> /// var thisWeeksMonday = DateTime.Now.GetWeekday(DayOfWeek.Monday); /// </code> /// </example> /// <remarks> /// modified by jtolar to implement culture settings /// </remarks> public static DateTime GetWeeksWeekday(this DateTime date, DayOfWeek weekday) { return(date.GetWeeksWeekday(weekday, ExtensionMethodSetting.DefaultCulture)); }
public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek) { return(this.helper.GetWeekOfYear(time, rule, firstDayOfWeek)); }
public override bool isWeekend(DayOfWeek w) { return(w == DayOfWeek.Saturday || w == DayOfWeek.Sunday); }
public pageMain() { GetSeasonVars(ref mstrSeason, ref mcolorBack, ref mcolorText); mDoW = WhatDay(); if (Device.RuntimePlatform == Device.iOS) { mstrSeason = " " + mstrSeason + " "; } if (Device.RuntimePlatform == Device.Android) { //set header bar color? } Button btnReading = new Button { Text = mstrSeason, BackgroundColor = mcolorBack, TextColor = mcolorText, BorderWidth = 0, BorderColor = mcolorBack }; btnReading.Clicked += (sender, args) => { //open readings page: Navigation.PushAsync(new pageReadings()); }; Button btnChurchSearch = new Button { Text = "Find mass/reconciliation", BackgroundColor = mcolorBack, TextColor = mcolorText, BorderWidth = 0, BorderColor = mcolorBack }; btnChurchSearch.Clicked += (sender, args) => { //open ch search page: Navigation.PushAsync(new pageChurchSearch()); }; Button btnBulletins = new Button { Text = "Parish Bulletins/Homilies", BackgroundColor = mcolorBack, TextColor = mcolorText, BorderWidth = 0, BorderColor = mcolorBack }; btnBulletins.Clicked += (sender, args) => { //open bulletins page: Navigation.PushAsync(new pageHomilies()); }; Button btnMysteries = new Button { Text = TodaysMysteries(mDoW), BackgroundColor = mcolorBack, TextColor = mcolorText, BorderWidth = 0, BorderColor = mcolorBack }; btnMysteries.Clicked += (sender, args) => { //open rosary mysteries page: Navigation.PushAsync(new pageMysteries(mDoW)); }; Image imgBack = new Image { Source = "stPete.png", IsVisible = true, Aspect = Aspect.AspectFit }; ToolbarItem tbMenu = new ToolbarItem { Text = "about", //custom menu work below for each platform }; switch (Device.RuntimePlatform) { case (Device.iOS): { tbMenu.Order = ToolbarItemOrder.Primary; ToolbarItems.Add(tbMenu); tbMenu.Clicked += (sender, args) => { Navigation.PushAsync(new pageAbout()); }; break; } case (Device.Android): { ToolbarItems.Add(new ToolbarItem("About", "info.png", () => { Navigation.PushAsync(new pageAbout()); })); break; } case (Device.UWP): { tbMenu.Icon = "info.png"; tbMenu.Order = ToolbarItemOrder.Default; ToolbarItems.Add(new ToolbarItem("About", "info.png", () => { Navigation.PushAsync(new pageAbout()); })); break; } } //swtich end Content = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.End, Padding = new Thickness(5), Spacing = 10, Children = { btnReading, btnChurchSearch, btnBulletins, btnMysteries } }; BackgroundImage = "stPete.png"; } //constructor - pageMain
/// <summary> /// 将星期几转成数字表示 /// </summary> private int ConvertDayOfWeek(DayOfWeek dayOfWeek) { return((int)dayOfWeek + 1); }
/// <summary> /// Gets the last occurrence of the given day of the month in the given DateTime. /// </summary> /// <param name="date">The given DateTime.</param> /// <param name="day">The day to be found.</param> /// <returns>DateTime instance of the last occurrence of the given day.</returns> public static DateTime GetLastDayOccurrenceOfTheMonth(this DateTime date, DayOfWeek day) { var lastDayOfMonth = date.GetLastDayOfTheMonth(); return(lastDayOfMonth.DayOfWeek == day ? lastDayOfMonth : lastDayOfMonth.GetPreviousDay(day)); }
public DaySchedule(string _info) { string[] str = _info.Split('+'); int i = 0; for (i = 0; i < str.Count(); i++) { if ((i + 1) == str.Count()) //i + 1 는 week가 저장 { break; } switch (str[i]) { case "D": work[i] = WORK.D; break; case "E": work[i] = WORK.E; break; case "N": work[i] = WORK.N; break; case "O": work[i] = WORK.O; break; case "V": work[i] = WORK.V; break; } } switch (str[i + 1]) { case "1": week = DayOfWeek.Monday; break; case "2": week = DayOfWeek.Tuesday; break; case "3": week = DayOfWeek.Wednesday; break; case "4": week = DayOfWeek.Thursday; break; case "5": week = DayOfWeek.Friday; break; case "6": week = DayOfWeek.Saturday; break; case "7": week = DayOfWeek.Sunday; break; } }
public string CreateSubsequentVersion(string projectKey, string versionPattern, int versionComponentToIncrement, DayOfWeek versionReleaseWeekday) { // Determine next version name var lastUnreleasedVersion = jiraProjectVersionFinder.FindUnreleasedVersions(projectKey, versionPattern).Last(); var nextVersionName = IncrementVersion(lastUnreleasedVersion.name, versionComponentToIncrement); // Determine next release day if (!lastUnreleasedVersion.releaseDate.HasValue) { throw new JiraException("releaseDate of lastUnreleasedVersion must have a value but is null"); } var nextReleaseDay = lastUnreleasedVersion.releaseDate.Value.AddDays(1); while (nextReleaseDay.DayOfWeek != versionReleaseWeekday) { nextReleaseDay = nextReleaseDay.AddDays(1); } var newVersionId = CreateVersion(projectKey, nextVersionName, nextReleaseDay); MoveVersion(newVersionId, lastUnreleasedVersion.self); return(newVersionId); }
/// <summary> /// Check if given <see cref="DayOfWeek"/> value is weekend. /// </summary> public static bool IsWeekend(this DayOfWeek dayOfWeek) { return(dayOfWeek.IsIn(DayOfWeek.Saturday, DayOfWeek.Sunday)); }
/// <summary> /// 每周某一天执行 /// </summary> /// <param name="dayOfWeek"></param> /// <param name="hour"></param> /// <param name="minute"></param> /// <returns></returns> protected ITrigger TriggerWeekly(DayOfWeek dayOfWeek, int hour, int minute, string name = null) => BuildTrigger(t => t.TriggerWeekly_(dayOfWeek, hour, minute, this.TriggerName(name)).Build());
/// <summary> /// Check if given <see cref="DayOfWeek"/> value is weekday. /// </summary> public static bool IsWeekday(this DayOfWeek dayOfWeek) { return(dayOfWeek.IsIn(DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday)); }
public static TransitionTime CreateFloatingDateRule(DateTime timeOfDay, int month, int week, DayOfWeek dayOfWeek) => new TransitionTime(timeOfDay, month, week, 1, dayOfWeek, isFixedDateRule: false);
/// <summary> /// Loads and returns all the cached schedules for the team between and including the past /// and future weeks. /// </summary> /// <param name="teamId">The ID of the team to return the cached schedules for.</param> /// <param name="pastWeeks">The number of past weeks to return.</param> /// <param name="futureWeeks">The number of future weeks to return.</param> /// <param name="startDayOfWeek">The start day of the week for the team.</param> /// <param name="scheduleCacheService">The schedule cache service to use to load the schedules.</param> /// <param name="timeService">The time service to use to get the current times.</param> /// <returns>The array of cached schedules.</returns> internal static async Task <CacheModel <ShiftModel>[]> LoadSchedulesAsync(string teamId, int pastWeeks, int futureWeeks, DayOfWeek startDayOfWeek, IScheduleCacheService scheduleCacheService, ISystemTimeService timeService) { var loadScheduleTasks = timeService.UtcNow .Range(pastWeeks, futureWeeks, startDayOfWeek) .Select(w => scheduleCacheService.LoadScheduleAsync(teamId, w)); return(await Task.WhenAll(loadScheduleTasks).ConfigureAwait(false)); }
private void InsertWeeklyTransactionsForCategory( IUnitOfWork unitOfWork, BankAccountEntity bankAccount, CategoryEntity category, DayOfWeek transactionDayOfWeek, string transactionName, string transactionDescription, int amountMinValue, int amountMaxValue) { var today = DateTime.Now.Date; // Make sure its a historical transaction var todayDayOfWeek = today.DayOfWeek; var dayDifference = todayDayOfWeek > transactionDayOfWeek ? transactionDayOfWeek - todayDayOfWeek : transactionDayOfWeek - todayDayOfWeek - 7; var startDate = today.AddDays(dayDifference); var transactions = new List <TransactionEntity>(); // Insert 2 years of weekly transactions for (var i = 0; i < 104; i++) { var amount = (decimal)_random.Next(amountMinValue * 100, amountMaxValue * 100) / 100; transactions.Add(new TransactionEntity { AccountNumber = "NL02ABNA9450889198", Amount = amount, BankAccount = bankAccount, Description = transactionDescription, Date = startDate.AddDays(-7 * i), TransactionCategories = new List <TransactionCategoryEntity> { new TransactionCategoryEntity { Amount = amount, Category = category } }, DestinationAccount = "NL83RABO2338418883", Name = transactionName, User = bankAccount.User }); } unitOfWork.TransactionRepository.InsertRange(transactions); }
public static int UnluckyDays(int year, DayOfWeek dayOfWeek) { return(Enumerable.Range(1, 12).Select(x => new DateTime(year, x, 13)).Count(x => x.DayOfWeek == dayOfWeek)); }
public DayOfWeekGroup(DayOfWeek dayOfWeek) { switch (dayOfWeek) { case DayOfWeek.Friday: this.Fri += 1; this.setPropertyAndValue("Fri", 1); break; case DayOfWeek.Monday: this.Mon += 1; this.setPropertyAndValue("Mon", 1); break; case DayOfWeek.Saturday: this.Sat += 1; this.setPropertyAndValue("Sat", 1); break; case DayOfWeek.Sunday: this.Sun += 1; this.setPropertyAndValue("Sun", 1); break; case DayOfWeek.Thursday: this.Thu += 1; this.setPropertyAndValue("Thu", 1); break; case DayOfWeek.Tuesday: this.Tue += 1; this.setPropertyAndValue("Tue", 1); break; case DayOfWeek.Wednesday: this.Wed += 1; this.setPropertyAndValue("Wed", 1); break; } }
/// <summary> /// Gets a DateTime representing the last specified day in the current month /// </summary> /// <param name="current">The current date</param> /// <param name="dayOfWeek">The current day of week</param> /// <returns></returns> public static DateTime Last(this DateTime current, DayOfWeek dayOfWeek) { DateTime last = current.Last(); last = last.AddDays(Math.Abs(dayOfWeek - last.DayOfWeek) * -1); return last; }