Example #1
0
 public MonthRange(Month startMonth, int startYear, Month endMonth, int endYear)
 {
     StartYear = startYear;
     StartMonth = (int)startMonth;
     EndMonth = (int)endMonth;
     EndYear = endYear;
 }
Example #2
0
 public CalendarDay(DayOfWeek dayOfWeek, int year, Month month, int dayOfMonth)
 {
     DayOfWeek = dayOfWeek;
     Year = year;
     Month = month;
     DayOfMonth = dayOfMonth;
 }
 public DayOfWeekAnnualReccurance(DayOfWeek dayOfWeek, WeekOfMonth week, Month month, bool substituteWeekend = true)
     : base(substituteWeekend)
 {
     DayOfWeek = dayOfWeek;
     Week = week;
     Month = month;
 }
Example #4
0
 /// <summary>
 /// Returns quarter date is in based on specifed
 /// start of year
 /// </summary>
 /// <param name="aDate"></param>
 /// <param name="startOfQuarter">Start of the year</param>
 /// <returns></returns>
 public static Quarter Quarter(this System.DateTime aDate, Month startOfYear)
 {
     int offset;
     offset = (((int)startOfYear -1) * -1) + aDate.Month;
     if(offset <= 0) offset = 12 - (Math.Abs(offset));
     return (Quarter)Math.Ceiling((double)((offset) / 3M));
 }
Example #5
0
 public static int GetMonthlyPrintNumber(Date date, int refNumber, Date refDate, Month noPrintMonths, Dictionary<int, int> noPrintDates, Dictionary<int, int> noPrintNumbers)
 {
     int no = refNumber;
     Date date2 = refDate;
     while (date > date2)
     {
         date2 = date2.AddMonths(1);
         Month month = zdate.GetMonth(date2.Month);
         if ((noPrintMonths & month) != month && !noPrintDates.ContainsKey(date2.AbsoluteDay))
         {
             do
             {
                 no++;
             } while (noPrintNumbers.ContainsKey(no));
         }
     }
     while (date < date2)
     {
         Month month = zdate.GetMonth(date2.Month);
         if ((noPrintMonths & month) != month && !noPrintDates.ContainsKey(date2.AbsoluteDay))
         {
             do
             {
                 no--;
             } while (noPrintNumbers.ContainsKey(no));
         }
         date2 = date2.AddMonths(-1);
     }
     return no;
 }
Example #6
0
 private Rain GetRandomRain(Month month, Cloudiness cloudiness) {
     double fraction = random.NextDouble();
     switch(month) {
         case Month.January:
         case Month.February:
         case Month.December:
             if(fraction < 0.05 && cloudiness != Cloudiness.Low)
                 return Rain.Heavy;
             else if(fraction < 0.2)
                 return Rain.Drizzle;
             else
                 return Rain.None;
         case Month.July:
         case Month.August:
             if(fraction < 0.05 && cloudiness != Cloudiness.Low)
                 return Rain.Thunderstorm;
             else if(fraction < 0.1)
                 return Rain.Heavy;
             else if(fraction < 0.3)
                 return Rain.Drizzle;
             else
                 return Rain.None;
         default:
             if(fraction < 0.01 && cloudiness != Cloudiness.Low)
                 return Rain.Thunderstorm;
             else if(fraction < 0.03)
                 return Rain.Heavy;
             else if(fraction < 0.1)
                 return Rain.Drizzle;
             else
                 return Rain.None;
     }
 }
        public void op_ToMonth_string()
        {
            var expected = new Month(2010, 11);
            var actual = "2010-11".ToMonth();

            Assert.Equal(expected, actual);
        }
        /// <summary>
        /// Creates a new LocalDate with the given year, month and day.
        /// </summary>
        /// <param name="year"></param>
        /// <param name="month"></param>
        /// <param name="day"></param>
        public LocalDate(int year, Month month, int day)
        {
            int monthNumber = month.Number();

            if (monthNumber < 1 || monthNumber > 12)
            {
                throw new ArgumentOutOfRangeException("month", "invalid month with number " + ((int)month));
            }

            if (day < 1)
            {
                throw new ArgumentOutOfRangeException("day", "day must be at least 1");
            }

            int monthLength = month.Length(DateTime.IsLeapYear(year));

            if (day > monthLength)
            {
                throw new ArgumentOutOfRangeException("day", month.Name() + " " + year + " has only " + monthLength + " days");
            }

            m_year = year;
            m_month = month;
            m_day = day;
        }
Example #9
0
 public void GetLateness(int nEmployeeID, Month aMonth, int aYear)
 {
     this.nEmployeeID = nEmployeeID;
     Ultis.DatesRange(out startDate, out endDate, aMonth, aYear);
     GetLatenessData();
     GenerateLatenessTable();
     CalculateLateness();
 }
Example #10
0
 public Gregorian(ITimeContext context, int year, Month month, int day, int hour = 0, int minute = 0, int second = 0, int milliseconds = 0, TimeZone timezone = null)
 {
     if (timezone == null)
         timezone = context.Gmt ();
     this.timezone = timezone;
     //TODO: Validate input
     this.time = new DateTime (year, (int)month, day, hour, minute, second, milliseconds, System.DateTimeKind.Utc).ToTime (context);
 }
Example #11
0
 public void CalculatePTServiceCommission(int aEmployeeID, string aBranchCode, Month aMonth, int aYear)
 {
     nEmployeeID = aEmployeeID;
     strBranchCode = aBranchCode;
     month = aMonth;
     year = aYear;
     ProcessCalculation();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="YearlyPattern"/> class.
 /// </summary>
 /// <param name="startDate">The date and time when the recurrence starts.</param>
 /// <param name="month">The month of the year each occurrence happens.</param>
 /// <param name="dayOfMonth">The day of the month each occurrence happens.</param>
 public YearlyPattern(
     DateTime startDate,
     Month month,
     int dayOfMonth)
     : base(startDate)
 {
     this.Month = month;
     this.DayOfMonth = dayOfMonth;
 }
Example #13
0
 public void AdvanceMonth()
 {
     this.month++;
     if (this.month == Month.December + 1)
     {
         this.month = Month.January;
         this.year++;
     }
 }
Example #14
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="T:OregonTrailDotNet.Window.MainMenu.NewGameInfo" /> class.
 /// </summary>
 public NewGameInfo()
 {
     PlayerNameIndex = 0;
     _playerNames = new List<string>();
     _playerProfession = Entity.Person.Profession.Banker;
     _startingInventory = new List<SimItem>();
     _startingMonies = 0;
     _startingMonth = Month.March;
     Modified = false;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TimeChangeRecurrence"/> class.
 /// </summary>
 /// <param name="dayOfTheWeekIndex">The index of the day in the month at which the time change occurs.</param>
 /// <param name="dayOfTheWeek">The day of the week the time change occurs.</param>
 /// <param name="month">The month the time change occurs.</param>
 public TimeChangeRecurrence(
     DayOfTheWeekIndex dayOfTheWeekIndex,
     DayOfTheWeek dayOfTheWeek,
     Month month)
     : this()
 {
     this.dayOfTheWeekIndex = dayOfTheWeekIndex;
     this.dayOfTheWeek = dayOfTheWeek;
     this.month = month;
 }
Example #16
0
 public static Quarter GetQuarter(Month month)
 {
     if (month <= Month.March)	// 1st Quarter = January 1 to March 31
         return Quarter.First;
     else if ((month >= Month.April) && (month <= Month.June)) // 2nd Quarter = April 1 to June 30
         return Quarter.Second;
     else if ((month >= Month.July) && (month <= Month.September)) // 3rd Quarter = July 1 to September 30
         return Quarter.Third;
     else // 4th Quarter = October 1 to December 31
         return Quarter.Fourth;
 }
        private Month CalculateMonth()
        {
            var month = new Month();

            month.MonthIndex = internalDateStore.Month;
            month.Year = internalDateStore.Year;
            month.Days = GetDaysInMonth();
            month.Name = string.Concat(GetMonthName(), " ", internalDateStore.Year.ToString());

            return month;
        }
 public static int GetNextDay(this int day, Month month, int year)
 {
     int daysInMonth = DateTime.DaysInMonth(year, (int)month);
     if (day == daysInMonth)
     {
         return 1;
     }
     else
     {
         return day + 1;
     }
 }
Example #19
0
        private DateTime GetFirstDayInGivenMonth(Month month)
        {
            int year = _currentDate.Year;

              if (_currentDate.Month < (int) month) {
            //this year
              }
              else {
            //Next year
            year++;
              }

              return new DateTime(year, (int) month, 1);
        }
Example #20
0
 public SlopeDayData(int aDay, Month aMonth, double aPercentOpen)
 {
     month = aMonth.ToString();
     day = aDay;
     percentOpen = aPercentOpen;
     int temp;
     temp = ((int)aMonth * 100) + day;
     dayMonth = "";
     if (temp < 1000)
     {
         dayMonth += "0";
     }
     dayMonth += temp.ToString();
 }
        private void PopulatePostCountsPerMonth(PostsByYear postsByYear, Month targetMonth,  Guid[] postsToExclude)
        {
            var monthlyPostCounts = from posts in _postsEntityContext.Entities
                                    where posts.YearOfPublication == postsByYear.Year
                                    group posts by posts.MonthOfPublication
                                    into stats
                                    select new {Month = (Month) stats.Key, Count = stats.Count()};

            foreach(var monthlyPostCount in monthlyPostCounts )
            {
                postsByYear.SetMonthCount(monthlyPostCount.Month,monthlyPostCount.Count);
            }

            postsByYear.IncrementPostCountForMonth(targetMonth);
        }
Example #22
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ClimateData" /> class.
 ///     Creates a new bit of climate data.
 /// </summary>
 /// <param name="month">Month this data is representative of.</param>
 /// <param name="averageTemp">Average set of temperatures for this month.</param>
 /// <param name="tempMax">Maximum temperature this month can have.</param>
 /// <param name="tempMin">Minimum temperature this month can have.</param>
 /// <param name="rainfall">Average rainfall for this month.</param>
 /// <param name="avgHumidity">Daily humidity for this month.</param>
 public ClimateData(
     Month month,
     float averageTemp,
     float tempMax,
     float tempMin,
     float rainfall,
     int avgHumidity)
 {
     Month = month;
     Temperature = averageTemp;
     TemperatureMax = tempMax;
     TemperatureMin = tempMin;
     Rainfall = rainfall;
     Humidity = avgHumidity;
 }
Example #23
0
        public void ctor_SerializationInfo_StreamingContext()
        {
            var expected = new Month(1999, 12);
            Month actual;

            using (Stream stream = new MemoryStream())
            {
                var formatter = new BinaryFormatter();
                formatter.Serialize(stream, new Month(1999, 12));
                stream.Position = 0;
                actual = (Month)formatter.Deserialize(stream);
            }

            Assert.Equal(expected, actual);
        }
Example #24
0
        public void ScheduleEveryYearOn(Month month, int day, TimeSpan timeOfDay)
        {
            if (!Enum.IsDefined(typeof(Month), month))
                throw new ArgumentOutOfRangeException("Invalid value for 'month'");

            DateTime today = DateTime.Now;

            DateTime max = DateTimeHelper.GetMax(today, StartDateTime);

            int expectedYear = max.Year;

            DateTime expectedDueDate = new DateTime(expectedYear, (int)month, day).Add(timeOfDay);

            if (expectedDueDate < max)
                expectedDueDate = expectedDueDate.AddYears(1);

            DueDateTime = expectedDueDate;
        }
Example #25
0
			/// <summary>
			/// Parse a date and time for format-date() 
			/// </summary>
			/// <param name="d"></param>
			/// <returns></returns>
			public static ExsltDateTime ParseDateTime(string d)
			{
				// First try any of the classes in ParseDate
				try
				{
					return ParseDate(d);
				}
				catch (FormatException)
				{
				}

				try
				{
					TimeTZ t = new TimeTZ(d);
					return t;
				}
				catch (FormatException)
				{
				}

				try
				{
					MonthDay t = new MonthDay(d);
					return t;
				}
				catch (FormatException)
				{
				}

				try
				{
					Month t = new Month(d);
					return t;
				}
				catch (FormatException)
				{
				}

				// Finally day -- don't catch the exception
				{
					Day t = new Day(d);
					return t;
				}
			}
    int MonthOfYear(Month month)
    {
        switch (month) {
            case Month.january:		return 1;
            case Month.february:	return 2;
            case Month.march:		return 3;
            case Month.april:		return 4;
            case Month.may:			return 5;
            case Month.june:		return 6;
            case Month.july:		return 7;
            case Month.august:		return 8;
            case Month.september:	return 9;
            case Month.october:		return 10;
            case Month.november:	return 11;
            case Month.december:	return 12;

            default: return -1;
        }
    }
Example #27
0
 public YearsBuilder OnMonth(DateTime dateTime)
 {
     switch(dateTime.Month)
     {
         case 1:
             _month = Month.JANUARY;
             break;
         case 2:
             _month = Month.FEBRUARY;
             break;
         case 3:
             _month = Month.MARCH;
             break;
         case 4:
             _month = Month.APRIL;
             break;
         case 5:
             _month = Month.MAY;
             break;
         case 6:
             _month = Month.JUNE;
             break;
         case 7:
             _month = Month.JULY;
             break;
         case 8:
             _month = Month.AUGUST;
             break;
         case 9:
             _month = Month.SEPTEMBER;
             break;
         case 10:
             _month = Month.OCTOBER;
             break;
         case 11:
             _month = Month.NOVEMBER;
             break;
         case 12:
             _month = Month.DECEMBER;
             break;
     }
     return this;
 }
Example #28
0
        public async void ReadMyXML(string year)
        {
            Months = new Months();

            Progress<int> progress = new Progress<int>((p) => { ProgressPercent = p; });

            BasicFileDownloader bidl = new BasicFileDownloader(ToAbsoluteUri("xmlmonths.aspx?ay=" + year));
            IRandomAccessStream s = await bidl.DownloadAsync(progress);

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments = true;
            settings.Async = true;
            XmlReader reader = XmlReader.Create(s.AsStream(), settings);
            reader.ReadStartElement("Model");
            reader.ReadStartElement("Months");
            Count = 0;
            while (reader.IsStartElement())
            {
                string month = reader[0];
                string str = reader[1];
                str = str.Replace("_s.jpg", "");
                if (!String.IsNullOrEmpty(str))
                {
                    uint count = 0;
                    if (uint.TryParse(reader[2], out count))
                    {
                        Month m = new Month(month, str, count);
                        Months.Add(m);
                        Count += m.Count;
                    }
                }
                await reader.ReadAsync();
            }
        }
        public AvailabilityModel()
        {
            Months = new List<Month>();
            var months = new[] {"Apr", "May", "Jun", "Jul", "Aug", "Sep"};
            var firstofMonth = new DateTime(DateTime.Now.Year, 4, 1);
            var firstSaturday = firstofMonth.AddDays(-(firstofMonth.DayOfWeek - DayOfWeek.Saturday));
            var sunday = firstSaturday.AddDays(1);

            var sundayFirstOfMonth = false;
            while (sunday < new DateTime(DateTime.Now.Year, 10, 1))
            {
                var month = MonthExists(months[firstSaturday.Month - 4]);

                if(month==null)
                {
                    month = new Month {Name = months[firstSaturday.Month - 4]};
                    Months.Add(month);
                }

                if (sundayFirstOfMonth && month.Days.Count == 0)
                {
                    month.Days.Add(new Day {Date = "01",Weekend = "Sun"});
                    sundayFirstOfMonth = false;
                }

                month.Days.Add(new Day{Date=firstSaturday.Day.ToString(CultureInfo.InvariantCulture).PadLeft(2,'0'),Weekend = "Sat"});
                if (!sundayFirstOfMonth) month.Days.Add(new Day { Date = sunday.Day.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0'), Weekend = "Sun"});

                firstSaturday = firstSaturday.AddDays(7);
                sunday = firstSaturday.AddDays(1);

                if (sunday.Day == 1) sundayFirstOfMonth = true;

            }        

        }
Example #30
0
 /// <summary>
 /// Renders the <see cref="Month"/> <paramref name="value"/>.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static string RenderParameterValue(this Month value) =>
 Enum.GetValues(typeof(Month)).OfType <Month>().Contains(value)
         ? $"{value}"
         : throw new InvalidOperationException($"'{typeof(Month).FullName}' value '{value}' is unsupported.");
Example #31
0
 public static IRule Day(this Month month, int day)
 {
     return(new DayInMonthRule(day, month));
 }
        public void FromDateTime_MonthTypeParameter_EqualsExpected(DateTime dateTime, Month expectedMonth)
        {
            var month = TimePeriodFactory.FromDateTime <Month>(dateTime);

            Assert.AreEqual(expectedMonth, month);
        }
Example #33
0
        public IDictionary <DayType, ICollection <DatesRange> > GetRanges(Month month)
        {
            var groups = month.Days.Where(d => d.Number > 0).OrderBy(d => d.Number).GroupBy(d => d.Type).ToDictionary(d => d.Key, d => d.Select(g => g.Number).ToList());

            var result = new Dictionary <DayType, ICollection <DatesRange> >();

            foreach (var group in groups)
            {
                var dayType = group.Key;

                if (!result.ContainsKey(dayType))
                {
                    result.Add(dayType, new List <DatesRange>());
                }

                var groupDays = group.Value;

                var ranges = new List <List <int> >();

                var currentRange = new List <int>();
                ranges.Add(currentRange);

                void createNewCurrentRange()
                {
                    currentRange = new List <int>();

                    ranges.Add(currentRange);
                }

                for (var i = 0; i < groupDays.Count(); i++)
                {
                    var day = groupDays[i];

                    var nextDayIndex = i + 1;

                    if (i > 0)
                    {
                        var previousDay = groupDays[i - 1];

                        if (day - previousDay > 1)
                        {
                            createNewCurrentRange();
                        }
                    }

                    if (nextDayIndex >= groupDays.Count())
                    {
                        currentRange.Add(day);

                        //createNewCurrentRange();

                        continue;
                    }

                    var nextDay = groupDays[nextDayIndex];

                    if (nextDay - day == 1)
                    {
                        currentRange.AddRange(new[] { day, nextDay });

                        i++;
                    }
                    else
                    {
                        currentRange.Add(day);

                        createNewCurrentRange();
                    }
                }

                foreach (var range in ranges)
                {
                    if (!range.Any())
                    {
                        continue;
                    }

                    var minDateNumber = range.Min();
                    var maxDateNumber = range.Max();

                    var minDate = new DateTime(month.Year, month.Number, minDateNumber);
                    var maxDate = new DateTime(month.Year, month.Number, maxDateNumber);

                    var datesRange = new DatesRange(minDate, maxDate);

                    result[dayType].Add(datesRange);
                }
            }

            return(result);
        }
Example #34
0
            public override bool isBusinessDay(Date date)
            {
                DayOfWeek w = date.DayOfWeek;
                int       d = date.Day, dd = date.DayOfYear;
                Month     m = (Month)date.Month;
                int       y = date.Year;

                if (isWeekend(w)
                    // New Year's Day
                    || (d == 1 && m == Month.January)
                    // 23 nisan / National Holiday
                    || (d == 23 && m == Month.April)
                    // 19 may/ National Holiday
                    || (d == 19 && m == Month.May)
                    // 15 july / National Holiday (since 2017)
                    || (d == 15 && m == Month.July && y >= 2017)
                    // 30 aug/ National Holiday
                    || (d == 30 && m == Month.August)
                    // 29 ekim  National Holiday
                    || (d == 29 && m == Month.October))
                {
                    return(false);
                }

                // Local Holidays
                if (y == 2004)
                {
                    // Kurban
                    if ((m == Month.February && d <= 4)
                        // Ramadan
                        || (m == Month.November && d >= 14 && d <= 16))
                    {
                        return(false);
                    }
                }
                else if (y == 2005)
                {
                    // Kurban
                    if ((m == Month.January && d >= 19 && d <= 21)
                        // Ramadan
                        || (m == Month.November && d >= 2 && d <= 5))
                    {
                        return(false);
                    }
                }
                else if (y == 2006)
                {
                    // Kurban
                    if ((m == Month.January && d >= 10 && d <= 13)
                        // Ramadan
                        || (m == Month.October && d >= 23 && d <= 25)
                        // Kurban
                        || (m == Month.December && d == 31))
                    {
                        return(false);
                    }
                }
                else if (y == 2007)
                {
                    // Kurban
                    if ((m == Month.January && d <= 3)
                        // Ramadan
                        || (m == Month.October && d >= 12 && d <= 14)
                        // Kurban
                        || (m == Month.December && d >= 20 && d <= 23))
                    {
                        return(false);
                    }
                }
                else if (y == 2008)
                {
                    // Ramadan
                    if ((m == Month.September && d == 30) ||
                        (m == Month.October && d <= 2)
                        // Kurban
                        || (m == Month.December && d >= 8 && d <= 11))
                    {
                        return(false);
                    }
                }
                else if (y == 2009)
                {
                    // Ramadan
                    if ((m == Month.September && d >= 20 && d <= 22)
                        // Kurban
                        || (m == Month.November && d >= 27 && d <= 30))
                    {
                        return(false);
                    }
                }
                else if (y == 2010)
                {
                    // Ramadan
                    if ((m == Month.September && d >= 9 && d <= 11)
                        // Kurban
                        || (m == Month.November && d >= 16 && d <= 19))
                    {
                        return(false);
                    }
                }
                else if (y == 2011)
                {
                    // not clear from borsainstanbul.com
                    if ((m == Month.October && d == 1) ||
                        (m == Month.November && d >= 9 && d <= 13))
                    {
                        return(false);
                    }
                }
                else if (y == 2012)
                {
                    // Ramadan
                    if ((m == Month.August && d >= 18 && d <= 21)
                        // Kurban
                        || (m == Month.October && d >= 24 && d <= 28))
                    {
                        return(false);
                    }
                }
                else if (y == 2013)
                {
                    // Ramadan
                    if ((m == Month.August && d >= 7 && d <= 10)
                        // Kurban
                        || (m == Month.October && d >= 14 && d <= 18)
                        // additional holiday for Republic Day
                        || (m == Month.October && d == 28))
                    {
                        return(false);
                    }
                }
                else if (y == 2014)
                {
                    // Ramadan
                    if ((m == Month.July && d >= 27 && d <= 30)
                        // Kurban
                        || (m == Month.October && d >= 4 && d <= 7)
                        // additional holiday for Republic Day
                        || (m == Month.October && d == 29))
                    {
                        return(false);
                    }
                }
                return(true);
            }
Example #35
0
 public void YearIsCorrect([Frozen] int expected, Month sut)
 {
     Assert.Equal <int>(expected, sut.Year);
 }
 /// <summary>
 /// ToString()
 /// </summary>
 public override string ToString()
 {
     return(Invariant($"{Year}/{Month.ToString("00", CultureInfo.InvariantCulture)}/{Day.ToString("00", CultureInfo.InvariantCulture)}"));
 }
Example #37
0
 public Double this[Month month]
 {
     get { return(this.productionRateForcast[month - Month.January]); }
     set { this.productionRateForcast[month - Month.January] = value; }
 }
Example #38
0
 /// <summary>Gets the next IMM date.
 /// </summary>
 /// <param name="date">The basis for the IMM date calculation.</param>
 /// <param name="month">The month of the IMM date in its <see cref="IMM.Month"/> representation.</param>
 /// <param name="yearOffset">The number of years to add to <paramref name="date"/> to take into account for IMM date calculation.</param>
 /// <returns>The next IMM date in month <paramref name="month"/> with respect to <paramref name="date"/> + <paramref name="yearOffset"/>.</returns>
 public static DateTime Next(DateTime date, Month month, int yearOffset)
 {
     return(GetNextDate(new DateTime(date.Year + yearOffset, (int)month, 1)));
 }
Example #39
0
 /// <summary>Creates a new <see cref="ITimeframeDescription"/> object, where the start date of the period is a IMM date.</summary>
 /// <param name="month">The month of the period start date in its <see cref="IMM.Month"/> representation.</param>
 /// <param name="periodStartYearOffset">The number of years to add to the reference date in <c>GetStartAndEndDate(.)</c> to take into account for the calculation of the specific IMM date.</param>
 /// <param name="tenor">The tenor that represents the time span.</param>
 /// <param name="startDateAdjustment">A business day convention used to compute the start date of the period, i.e. the IMM date.</param>
 /// <param name="endDateAdjustment">A business day convention used to compute the end date of the period.</param>
 /// <returns>The specified <see cref="ITimeframeDescription"/> object.</returns>
 public static ITimeframeDescription Create(Month month, int periodStartYearOffset, TenorTimeSpan tenor, IBusinessDayConvention startDateAdjustment, IBusinessDayConvention endDateAdjustment)
 {
     return(new SpecificPeriod(month, periodStartYearOffset, tenor, startDateAdjustment, endDateAdjustment));
 }
 internal MonthRenderer(Month input) : base(input)
 {
 }
Example #41
0
 public DayInMonthRule(int dayInMonth, Month month)
 {
     DayInMonth = dayInMonth;
     Month      = month;
 }
Example #42
0
 public static DateTime FirstDay(this Month month, int year)
 => new DateTime(year, (int)month, 1);
 public List <Payment> GetPaymentsOfSelectedMonthByCustomerId(Customer customer, Month month)
 {
     return(customer.Payments.Where(x => x.MonthId == month).ToList());
 }
Example #44
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["concat"]      = new Concat();
     Functions["textjoin"]    = new Textjoin();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["search"]      = new Search();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     Functions["value"]       = new Value(CultureInfo.CurrentCulture);
     Functions["trim"]        = new Trim();
     Functions["clean"]       = new Clean();
     Functions["unicode"]     = new Unicode();
     Functions["unichar"]     = new Unichar();
     Functions["numbervalue"] = new NumberValue();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["abs"]             = new Abs();
     Functions["asin"]            = new Asin();
     Functions["asinh"]           = new Asinh();
     Functions["acot"]            = new Acot();
     Functions["acoth"]           = new Acoth();
     Functions["cos"]             = new Cos();
     Functions["cot"]             = new Cot();
     Functions["coth"]            = new Coth();
     Functions["cosh"]            = new Cosh();
     Functions["csc"]             = new Csc();
     Functions["csch"]            = new Csch();
     Functions["power"]           = new Power();
     Functions["gcd"]             = new Gcd();
     Functions["lcm"]             = new Lcm();
     Functions["sec"]             = new Sec();
     Functions["sech"]            = new SecH();
     Functions["sign"]            = new Sign();
     Functions["sqrt"]            = new Sqrt();
     Functions["sqrtpi"]          = new SqrtPi();
     Functions["pi"]              = new Pi();
     Functions["product"]         = new Product();
     Functions["ceiling"]         = new Ceiling();
     Functions["ceiling.precise"] = new CeilingPrecise();
     Functions["ceiling.math"]    = new CeilingMath();
     Functions["iso.ceiling"]     = new IsoCeiling();
     Functions["combin"]          = new Combin();
     Functions["combina"]         = new Combina();
     Functions["count"]           = new Count();
     Functions["counta"]          = new CountA();
     Functions["countblank"]      = new CountBlank();
     Functions["countif"]         = new CountIf();
     Functions["countifs"]        = new CountIfs();
     Functions["fact"]            = new Fact();
     Functions["factdouble"]      = new FactDouble();
     Functions["floor"]           = new Floor();
     Functions["floor.precise"]   = new FloorPrecise();
     Functions["floor.math"]      = new FloorMath();
     Functions["radians"]         = new Radians();
     Functions["roman"]           = new Roman();
     Functions["sin"]             = new Sin();
     Functions["sinh"]            = new Sinh();
     Functions["sum"]             = new Sum();
     Functions["sumif"]           = new SumIf();
     Functions["sumifs"]          = new SumIfs();
     Functions["sumproduct"]      = new SumProduct();
     Functions["sumsq"]           = new Sumsq();
     Functions["sumxmy2"]         = new Sumxmy2();
     Functions["sumx2my2"]        = new SumX2mY2();
     Functions["sumx2py2"]        = new SumX2pY2();
     Functions["seriessum"]       = new Seriessum();
     Functions["stdev"]           = new Stdev();
     Functions["stdevp"]          = new StdevP();
     Functions["stdev.s"]         = new StdevDotS();
     Functions["stdev.p"]         = new StdevDotP();
     Functions["subtotal"]        = new Subtotal();
     Functions["exp"]             = new Exp();
     Functions["log"]             = new Log();
     Functions["log10"]           = new Log10();
     Functions["ln"]              = new Ln();
     Functions["max"]             = new Max();
     Functions["maxa"]            = new Maxa();
     Functions["median"]          = new Median();
     Functions["min"]             = new Min();
     Functions["mina"]            = new Mina();
     Functions["mod"]             = new Mod();
     Functions["mode"]            = new Mode();
     Functions["mode.sngl"]       = new ModeSngl();
     Functions["mround"]          = new Mround();
     Functions["average"]         = new Average();
     Functions["averagea"]        = new AverageA();
     Functions["averageif"]       = new AverageIf();
     Functions["averageifs"]      = new AverageIfs();
     Functions["round"]           = new Round();
     Functions["rounddown"]       = new Rounddown();
     Functions["roundup"]         = new Roundup();
     Functions["rand"]            = new Rand();
     Functions["randbetween"]     = new RandBetween();
     Functions["rank"]            = new Rank();
     Functions["rank.eq"]         = new RankEq();
     Functions["rank.avg"]        = new RankAvg();
     Functions["percentile"]      = new Percentile();
     Functions["percentile.inc"]  = new PercentileInc();
     Functions["percentrank"]     = new Percentrank();
     Functions["percentrank.inc"] = new PercentrankInc();
     Functions["quotient"]        = new Quotient();
     Functions["trunc"]           = new Trunc();
     Functions["tan"]             = new Tan();
     Functions["tanh"]            = new Tanh();
     Functions["atan"]            = new Atan();
     Functions["atan2"]           = new Atan2();
     Functions["atanh"]           = new Atanh();
     Functions["acos"]            = new Acos();
     Functions["acosh"]           = new Acosh();
     Functions["var"]             = new Var();
     Functions["var.s"]           = new VarDotS();
     Functions["varp"]            = new VarP();
     Functions["var.p"]           = new VarDotP();
     Functions["large"]           = new Large();
     Functions["small"]           = new Small();
     Functions["degrees"]         = new Degrees();
     Functions["odd"]             = new Odd();
     Functions["even"]            = new Even();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     Functions["type"]       = new TypeFunction();
     // Logical
     Functions["if"]      = new If();
     Functions["ifs"]     = new Ifs();
     Functions["maxifs"]  = new MaxIfs();
     Functions["minifs"]  = new MinIfs();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     Functions["switch"]  = new Switch();
     // Reference and lookup
     Functions["address"]  = new Address();
     Functions["hlookup"]  = new HLookup();
     Functions["vlookup"]  = new VLookup();
     Functions["lookup"]   = new Lookup();
     Functions["match"]    = new Match();
     Functions["row"]      = new Row();
     Functions["rows"]     = new Rows();
     Functions["column"]   = new Column();
     Functions["columns"]  = new Columns();
     Functions["choose"]   = new Choose();
     Functions["index"]    = new RefAndLookup.Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset();
     // Date
     Functions["date"]             = new Date();
     Functions["today"]            = new Today();
     Functions["now"]              = new Now();
     Functions["day"]              = new Day();
     Functions["month"]            = new Month();
     Functions["year"]             = new Year();
     Functions["time"]             = new Time();
     Functions["hour"]             = new Hour();
     Functions["minute"]           = new Minute();
     Functions["second"]           = new Second();
     Functions["weeknum"]          = new Weeknum();
     Functions["weekday"]          = new Weekday();
     Functions["days"]             = new Days();
     Functions["days360"]          = new Days360();
     Functions["yearfrac"]         = new Yearfrac();
     Functions["edate"]            = new Edate();
     Functions["eomonth"]          = new Eomonth();
     Functions["isoweeknum"]       = new IsoWeekNum();
     Functions["workday"]          = new Workday();
     Functions["workday.intl"]     = new WorkdayIntl();
     Functions["networkdays"]      = new Networkdays();
     Functions["networkdays.intl"] = new NetworkdaysIntl();
     Functions["datevalue"]        = new DateValue();
     Functions["timevalue"]        = new TimeValue();
     // Database
     Functions["dget"]     = new Dget();
     Functions["dcount"]   = new Dcount();
     Functions["dcounta"]  = new DcountA();
     Functions["dmax"]     = new Dmax();
     Functions["dmin"]     = new Dmin();
     Functions["dsum"]     = new Dsum();
     Functions["daverage"] = new Daverage();
     Functions["dvar"]     = new Dvar();
     Functions["dvarp"]    = new Dvarp();
     //Finance
     Functions["cumipmt"]    = new Cumipmt();
     Functions["cumprinc"]   = new Cumprinc();
     Functions["ddb"]        = new Ddb();
     Functions["effect"]     = new Effect();
     Functions["fvschedule"] = new FvSchedule();
     Functions["pduration"]  = new Pduration();
     Functions["rri"]        = new Rri();
     Functions["pmt"]        = new Pmt();
     Functions["ppmt"]       = new Ppmt();
     Functions["ipmt"]       = new Ipmt();
     Functions["ispmt"]      = new IsPmt();
     Functions["pv"]         = new Pv();
     Functions["fv"]         = new Fv();
     Functions["npv"]        = new Npv();
     Functions["rate"]       = new Rate();
     Functions["nper"]       = new Nper();
     Functions["nominal"]    = new Nominal();
     Functions["irr"]        = new Irr();
     Functions["mirr"]       = new Mirr();
     Functions["xirr"]       = new Xirr();
     Functions["sln"]        = new Sln();
     Functions["syd"]        = new Syd();
     Functions["xnpv"]       = new Xnpv();
     Functions["coupdays"]   = new Coupdays();
     Functions["coupdaysnc"] = new Coupdaysnc();
     Functions["coupdaybs"]  = new Coupdaybs();
     Functions["coupnum"]    = new Coupnum();
     Functions["coupncd"]    = new Coupncd();
     Functions["couppcd"]    = new Couppcd();
     Functions["price"]      = new Price();
     Functions["yield"]      = new Yield();
     Functions["duration"]   = new Duration();
     Functions["disc"]       = new Disc();
     //Engineering
     Functions["bitand"]       = new BitAnd();
     Functions["bitor"]        = new BitOr();
     Functions["bitxor"]       = new BitXor();
     Functions["bitlshift"]    = new BitLshift();
     Functions["bitrshift"]    = new BitRshift();
     Functions["convert"]      = new ConvertFunction();
     Functions["bin2dec"]      = new Bin2Dec();
     Functions["bin2hex"]      = new Bin2Hex();
     Functions["bin2oct"]      = new Bin2Oct();
     Functions["dec2bin"]      = new Dec2Bin();
     Functions["dec2hex"]      = new Dec2Hex();
     Functions["dec2oct"]      = new Dec2Oct();
     Functions["hex2bin"]      = new Hex2Bin();
     Functions["hex2dec"]      = new Hex2Dec();
     Functions["hex2oct"]      = new Hex2Oct();
     Functions["oct2bin"]      = new Oct2Bin();
     Functions["oct2dec"]      = new Oct2Dec();
     Functions["oct2hex"]      = new Oct2Hex();
     Functions["delta"]        = new Delta();
     Functions["erf"]          = new Erf();
     Functions["erf.precise"]  = new ErfPrecise();
     Functions["erfc"]         = new Erfc();
     Functions["erfc.precise"] = new ErfcPrecise();
     Functions["besseli"]      = new BesselI();
     Functions["besselj"]      = new BesselJ();
     Functions["besselk"]      = new BesselK();
     Functions["bessely"]      = new BesselY();
 }
Example #45
0
 partial void OnMonthChanging(Month value);
Example #46
0
 public ValidThru(Month month, short year)
 {
     Month = month;
     Year  = year;
 }
Example #47
0
 public void MonthIsCorrect([Frozen] int expected, Month sut)
 {
     Assert.Equal <int>(expected, sut.MonthNumber);
 }
        public static void RemoveEvent(this Month month, ICalendarViewEvent calendarViewEvent)
        {
            var eventDate = calendarViewEvent.StartDateTime.Date;

            month.Days.FirstOrDefault(day => day.DateTime.Date.Equals(eventDate))?.RemoveEvent(calendarViewEvent);
        }
Example #49
0
            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 || (d == 3 && w == DayOfWeek.Monday)) && m == Month.January)
                    // Chakri Memorial Day
                    || ((d == 6 || ((d == 7 || d == 8) && w == DayOfWeek.Monday)) && m == Month.April)
                    // Songkran Festival
                    || ((d == 13 || d == 14 || d == 15) && m == Month.April)
                    // Songkran Festival obersvence (usually not more then 1 holiday will be replaced)
                    || (d == 16 && (w == DayOfWeek.Monday || w == DayOfWeek.Tuesday) && m == Month.April)
                    // Labor Day
                    || ((d == 1 || ((d == 2 || d == 3) && w == DayOfWeek.Monday)) && m == Month.May)
                    // H.M. the King's Birthday
                    || ((d == 28 || ((d == 29 || d == 30) && w == DayOfWeek.Monday)) && m == Month.July && y >= 2017)
                    // H.M. the Queen's Birthday
                    || ((d == 12 || ((d == 13 || d == 14) && w == DayOfWeek.Monday)) && m == Month.August)
                    // H.M. King Bhumibol Adulyadej Memorial Day
                    || ((d == 3 || ((d == 14 || d == 15) && w == DayOfWeek.Monday)) && m == Month.October && y >= 2017)
                    // H.M. King Bhumibol Adulyadej's Birthday
                    || ((d == 5 || ((d == 6 || d == 7) && w == DayOfWeek.Monday)) && m == Month.December)
                    // Constitution Day
                    || ((d == 10 || ((d == 11 || d == 12) && w == DayOfWeek.Monday)) && m == Month.December)
                    // New Year’s Eve
                    || (d == 31 && m == Month.December)
                    // New Year’s Eve Observence
                    || ((d == 1 || d == 2) && w == DayOfWeek.Monday && m == Month.January)
                    )
                {
                    return(false);
                }

                if ((y == 2000) &&
                    ((d == 21 && m == Month.February) || // Makha Bucha Day (Substitution Day)
                     (d == 5 && m == Month.May) ||       // Coronation Day
                     (d == 17 && m == Month.May) ||      // Wisakha Bucha Day
                     (d == 17 && m == Month.July) ||     // Buddhist Lent Day
                     (d == 23 && m == Month.October)     // Chulalongkorn Day
                    ))
                {
                    return(false);
                }

                if ((y == 2001) &&
                    ((d == 8 && m == Month.February) || // Makha Bucha Day
                     (d == 7 && m == Month.May) ||      // Wisakha Bucha Day
                     (d == 8 && m == Month.May) ||      // Coronation Day (Substitution Day)
                     (d == 6 && m == Month.July) ||     // Buddhist Lent Day
                     (d == 23 && m == Month.October)    // Chulalongkorn Day
                    ))
                {
                    return(false);
                }

                // 2002, 2003 and 2004 are missing

                if ((y == 2005) &&
                    ((d == 23 && m == Month.February) || // Makha Bucha Day
                     (d == 5 && m == Month.May) ||       // Coronation Day
                     (d == 23 && m == Month.May) ||      // Wisakha Bucha Day (Substitution Day for Sunday 22 May)
                     (d == 1 && m == Month.July) ||      // Mid Year Closing Day
                     (d == 22 && m == Month.July) ||     // Buddhist Lent Day
                     (d == 24 && m == Month.October)     // Chulalongkorn Day (Substitution Day for Sunday 23 October)
                    ))
                {
                    return(false);
                }

                if ((y == 2006) &&
                    ((d == 13 && m == Month.February) || // Makha Bucha Day
                     (d == 19 && m == Month.April) ||    // Special Holiday
                     (d == 5 && m == Month.May) ||       // Coronation Day
                     (d == 12 && m == Month.May) ||      // Wisakha Bucha Day
                     (d == 12 && m == Month.June)        // Special Holidays (Due to the auspicious occasion of the
                     // celebration of 60th Anniversary of His Majesty's Accession
                     // to the throne. For Bangkok, Samut Prakan, Nonthaburi,
                     // Pathumthani and Nakhon Pathom province)
                     || (d == 13 && m == Month.June) || // Special Holidays (as above)
                     (d == 11 && m == Month.July) ||    // Buddhist Lent Day
                     (d == 23 && m == Month.October)    // Chulalongkorn Day
                    ))
                {
                    return(false);
                }

                if ((y == 2007) &&
                    ((d == 5 && m == Month.March) ||  // Makha Bucha Day (Substitution Day for Saturday 3 March)
                     (d == 7 && m == Month.May) ||    // Coronation Day (Substitution Day for Saturday 5 May)
                     (d == 31 && m == Month.May) ||   // Wisakha Bucha Day
                     (d == 30 && m == Month.July) ||  // Asarnha Bucha Day (Substitution Day for Sunday 29 July)
                     (d == 23 && m == Month.October) || // Chulalongkorn Day
                     (d == 24 && m == Month.December) // Special Holiday
                    ))
                {
                    return(false);
                }

                if ((y == 2008) &&
                    ((d == 21 && m == Month.February) || // Makha Bucha Day
                     (d == 5 && m == Month.May) ||       // Coronation Day
                     (d == 19 && m == Month.May) ||      // Wisakha Bucha Day
                     (d == 1 && m == Month.July) ||      // Mid Year Closing Day
                     (d == 17 && m == Month.July) ||     // Asarnha Bucha Day
                     (d == 23 && m == Month.October)     // Chulalongkorn Day
                    ))
                {
                    return(false);
                }

                if ((y == 2009) &&
                    ((d == 2 && m == Month.January) || // Special Holiday
                     (d == 9 && m == Month.February) || // Makha Bucha Day
                     (d == 5 && m == Month.May) ||     // Coronation Day
                     (d == 8 && m == Month.May) ||     // Wisakha Bucha Day
                     (d == 1 && m == Month.July) ||    // Mid Year Closing Day
                     (d == 6 && m == Month.July) ||    // Special Holiday
                     (d == 7 && m == Month.July) ||    // Asarnha Bucha Day
                     (d == 23 && m == Month.October)   // Chulalongkorn Day
                    ))
                {
                    return(false);
                }

                if ((y == 2010) &&
                    ((d == 1 && m == Month.March) || // Substitution for Makha Bucha Day(Sunday 28 February)
                     (d == 5 && m == Month.May) ||   // Coronation Day
                     (d == 20 && m == Month.May) ||  // Special Holiday
                     (d == 21 && m == Month.May) ||  // Special Holiday
                     (d == 28 && m == Month.May) ||  // Wisakha Bucha Day
                     (d == 1 && m == Month.July) ||  // Mid Year Closing Day
                     (d == 26 && m == Month.July) || // Asarnha Bucha Day
                     (d == 13 && m == Month.August) || // Special Holiday
                     (d == 25 && m == Month.October) // Substitution for Chulalongkorn Day(Saturday 23 October)
                    ))
                {
                    return(false);
                }

                if ((y == 2011) &&
                    ((d == 18 && m == Month.February) || // Makha Bucha Day
                     (d == 5 && m == Month.May) ||       // Coronation Day
                     (d == 16 && m == Month.May) ||      // Special Holiday
                     (d == 17 && m == Month.May) ||      // Wisakha Bucha Day
                     (d == 1 && m == Month.July) ||      // Mid Year Closing Day
                     (d == 15 && m == Month.July) ||     // Asarnha Bucha Day
                     (d == 24 && m == Month.October)     // Substitution for Chulalongkorn Day(Sunday 23 October)
                    ))
                {
                    return(false);
                }

                if ((y == 2012) &&
                    ((d == 3 && m == Month.January) || // Special Holiday
                     (d == 7 && m == Month.March) ||   // Makha Bucha Day 2/
                     (d == 9 && m == Month.April) ||   // Special Holiday
                     (d == 7 && m == Month.May) ||     // Substitution for Coronation Day(Saturday 5 May)
                     (d == 4 && m == Month.June) ||    // Wisakha Bucha Day
                     (d == 2 && m == Month.August) ||  // Asarnha Bucha Day
                     (d == 23 && m == Month.October)   // Chulalongkorn Day
                    ))
                {
                    return(false);
                }

                if ((y == 2013) &&
                    ((d == 25 && m == Month.February) || // Makha Bucha Day
                     (d == 6 && m == Month.May) ||       // Substitution for Coronation Day(Sunday 5 May)
                     (d == 24 && m == Month.May) ||      // Wisakha Bucha Day
                     (d == 1 && m == Month.July) ||      // Mid Year Closing Day
                     (d == 22 && m == Month.July) ||     // Asarnha Bucha Day 2/
                     (d == 23 && m == Month.October) || // Chulalongkorn Day
                     (d == 30 && m == Month.December)    // Special Holiday
                    ))
                {
                    return(false);
                }

                if ((y == 2014) &&
                    ((d == 14 && m == Month.February) || // Makha Bucha Day
                     (d == 5 && m == Month.May) ||       // Coronation Day
                     (d == 13 && m == Month.May) ||      // Wisakha Bucha Day
                     (d == 1 && m == Month.July) ||      // Mid Year Closing Day
                     (d == 11 && m == Month.July) ||     // Asarnha Bucha Day 1/
                     (d == 11 && m == Month.August) ||   // Special Holiday
                     (d == 23 && m == Month.October)     // Chulalongkorn Day
                    ))
                {
                    return(false);
                }

                if ((y == 2015) &&
                    ((d == 2 && m == Month.January) || // Special Holiday
                     (d == 4 && m == Month.March) ||   // Makha Bucha Day
                     (d == 4 && m == Month.May) ||     // Special Holiday
                     (d == 5 && m == Month.May) ||     // Coronation Day
                     (d == 1 && m == Month.June) ||    // Wisakha Bucha Day
                     (d == 1 && m == Month.July) ||    // Mid Year Closing Day
                     (d == 30 && m == Month.July) ||   // Asarnha Bucha Day 1/
                     (d == 23 && m == Month.October)   // Chulalongkorn Day
                    ))
                {
                    return(false);
                }

                if ((y == 2016) &&
                    ((d == 22 && m == Month.February) || // Makha Bucha Day
                     (d == 5 && m == Month.May) ||       // Coronation Day
                     (d == 6 && m == Month.May) ||       // Special Holiday
                     (d == 20 && m == Month.May) ||      // Wisakha Bucha Day
                     (d == 1 && m == Month.July) ||      //  Mid Year Closing Day
                     (d == 18 && m == Month.July) ||     // Special Holiday
                     (d == 19 && m == Month.July) ||     // Asarnha Bucha Day 1/
                     (d == 24 && m == Month.October)     // Substitution for Chulalongkorn Day (Sunday 23rd October)
                    ))
                {
                    return(false);
                }

                // 2017 is missing

                if ((y == 2018) &&
                    ((d == 1 && m == Month.March) || // Makha Bucha Day
                     (d == 29 && m == Month.May) ||  // Wisakha Bucha Day
                     (d == 27 && m == Month.July) || // Asarnha Bucha Day1
                     (d == 23 && m == Month.October) // Chulalongkorn Day
                    ))
                {
                    return(false);
                }

                return(true);
            }
 public static void SelectDay(this Month month, Day selectedDay)
 {
     UnSelectCurrentDay(month);
     SelectNewDay(selectedDay, month);
 }
Example #51
0
 /// <summary>
 /// Metoda, která vyhledá záznamy podle zadaných parametrů, buď podle jedno nebo až tří
 /// </summary>
 /// <param name="category">Kategorie výdajů</param>
 /// <param name="balance">Typ zůstatku bankovní účet nebo hotovost</param>
 /// <param name="month">Měsíc kdy byla transakce uskutečněna</param>
 public void FindFinanceRecords(TypeRecord type, Category category, TypeBalance balance, Month month)
 {
     admin.FindRecords(type, category, balance, month);
     ViewGraphicFinance(3, true, false);
 }
Example #52
0
        public static Instant NextValid(
            this Instant instant,
            Month month     = Month.Every,
            Week week       = Week.Every,
            Day day         = Day.Every,
            WeekDay weekDay = WeekDay.Every,
            Hour hour       = Hour.Zeroth,
            Minute minute   = Minute.Zeroth,
            Second second   = Second.Zeroth,
            [CanBeNull] CalendarSystem calendarSystem = null,
            [CanBeNull] DateTimeZone timeZone         = null)
        {
            // Never case, if any are set to never, we'll never get a valid date.
            if ((month == Month.Never) ||
                (week == Week.Never) ||
                (day == Day.Never) ||
                (weekDay == WeekDay.Never) ||
                (hour == Hour.Never) ||
                (minute == Minute.Never) ||
                (second == Second.Never))
            {
                return(Instant.MaxValue);
            }

            if (calendarSystem == null)
            {
                calendarSystem = CalendarSystem.Iso;
            }
            if (timeZone == null)
            {
                timeZone = DateTimeZone.Utc;
            }
            Debug.Assert(calendarSystem != null);
            Debug.Assert(timeZone != null);

            // Move to next second.
            instant = instant.CeilingSecond();

            // Every second case.
            if ((month == Month.Every) &&
                (day == Day.Every) &&
                (weekDay == WeekDay.Every) &&
                (hour == Hour.Every) &&
                (minute == Minute.Every) &&
                (second == Second.Every) &&
                (week == Week.Every))
            {
                return(instant);
            }

            // Get days and months.
            int[] days   = Days(day).OrderBy(dy => dy).ToArray();
            int[] months = month.Months().ToArray();

            // Remove months where the first day isn't in the month.
            int firstDay = days.First();

            if (firstDay > 28)
            {
                // 2000 is a leap year, so February has 29 days.
                months = months.Where(mn => calendarSystem.GetDaysInMonth(2000, mn) >= firstDay).ToArray();
                if (months.Length < 1)
                {
                    return(Instant.MaxValue);
                }
            }

            // Get zoned date time.
            ZonedDateTime zdt = new ZonedDateTime(instant, timeZone, calendarSystem);
            int           y   = zdt.Year;
            int           m   = zdt.Month;
            int           d   = zdt.Day;
            int           h   = zdt.Hour;
            int           n   = zdt.Minute;
            int           s   = zdt.Second;

            int[] weeks = week.Weeks().ToArray();

            IsoDayOfWeek[] weekDays = weekDay.WeekDays().ToArray();
            int[]          hours    = hour.Hours().OrderBy(i => i).ToArray();
            int[]          minutes  = minute.Minutes().OrderBy(i => i).ToArray();
            int[]          seconds  = second.Seconds().ToArray();

            do
            {
                foreach (int currentMonth in months)
                {
                    if (currentMonth < m)
                    {
                        continue;
                    }
                    if (currentMonth > m)
                    {
                        d = 1;
                        h = n = s = 0;
                    }
                    m = currentMonth;
                    foreach (int currentDay in days)
                    {
                        if (currentDay < d)
                        {
                            continue;
                        }
                        if (currentDay > d)
                        {
                            h = n = s = 0;
                        }
                        d = currentDay;

                        // Check day is valid for this month.
                        if (d > calendarSystem.GetDaysInMonth(y, m))
                        {
                            break;
                        }

                        // We have a potential day, check week and week day
                        zdt = timeZone.AtLeniently(new LocalDateTime(y, m, d, h, n, s, calendarSystem));
                        if ((week != Week.Every) &&
                            (!weeks.Contains(zdt.WeekOfWeekYear)))
                        {
                            continue;
                        }
                        if ((weekDay != WeekDay.Every) &&
                            (!weekDays.Contains(zdt.IsoDayOfWeek)))
                        {
                            continue;
                        }

                        // We have a date match, check time.
                        foreach (int currentHour in hours)
                        {
                            if (currentHour < h)
                            {
                                continue;
                            }
                            if (currentHour > h)
                            {
                                n = s = 0;
                            }
                            h = currentHour;
                            foreach (int currentMinute in minutes)
                            {
                                if (currentMinute < n)
                                {
                                    continue;
                                }
                                if (currentMinute > n)
                                {
                                    s = 0;
                                }
                                n = currentMinute;
                                foreach (int currentSecond in seconds)
                                {
                                    if (currentSecond < s)
                                    {
                                        continue;
                                    }
                                    return
                                        (timeZone.AtLeniently(
                                             new LocalDateTime(y, m, d, h, n, currentSecond, calendarSystem)).ToInstant());
                                }
                                n = s = 0;
                            }
                            h = n = s = 0;
                        }
                        d = 1;
                    }
                    d = 1;
                    h = n = s = 0;
                }
                y++;

                // Don't bother checking max year.
                if (y >= calendarSystem.MaxYear)
                {
                    return(Instant.MaxValue);
                }

                // Start next year
                m = d = 1;
                h = n = s = 0;
            } while (true);
        }
 public static Day GetSelectedDay(this Month month)
 {
     return(month.Days.FirstOrDefault(day => day.IsSelected));
 }
Example #54
0
        /// <summary>
        /// Spočítá veškeré parametry pro vyhodnocení statistiky za měsíc či rok - denní útrata, měsíční výdaje - příjmy apod
        /// </summary>
        /// <param name="month">Měsíc ve kterém se spočítá statistika</param>
        /// <param name="yearString">Rok ve kterém se spočítá statistika</param>
        /// <param name="type">0 - Výpočet pro měsíc ** 1 - Výpočet pro rok</param>
        public void CalculateStatisticParametres(int month, string yearString, byte type)
        {
            int.TryParse(yearString, out int year);
            // Získám měsíc ve výčtovém typu
            Month monthType = Month.Other;

            if (month >= 0 && month <= 12)
            {
                monthType = (Month)month;
            }
            // Kolekce, která obsahuje první a konečný den zkoumaných týdnů
            List <DateTime> weeks  = Week.GetWeek(month + 1, year);
            List <double>   result = new List <double>();

            // Data pro měsíc nebo pro rok
            if (monthType != Month.Other && type == 0)
            {
                result = admin.CalculateStatisticParametres(monthType, year, type);
            }
            else if (type == 1)
            {
                result = admin.CalculateStatisticParametres(Month.Other, year, type);
            }
            // Vzdálenosti záznamů od sebe
            int headHeight = 35;
            // Výška jednoho řádků
            int heightChange = 22;
            // Pomocná proměnná, která obsahuje pozici pro vykreslení nového objektu
            int sumHeight = 0;
            // Výška předělů ve vykreslení - tmavě zelené bloky
            int splitHeight = 0;
            // Pomocné incrementy
            int n        = 0;
            int monthInc = 0;
            int inc      = 0;

            canvas.Children.Clear();
            string[] names = new string[] { "Příjmy", "Výdaje", "Bilance", "Den", "Týden", "Týden", "Týden", "Týden", "Týden", "Týden",
                                            "Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec" };
            // Pro každou získanou honotu ze správce se vykreslí řádek - modrý a bílý obdelník + název a suma
            for (int i = 0; i < result.Count; i++)
            {
                sumHeight = i * headHeight;
                if (i > 4)
                {
                    if (type == 0)
                    {
                        heightChange = 50;
                        sumHeight    = 5 * 35 + ((i - 5) * 55);
                    }
                    else if (type == 1)
                    {
                        heightChange = 22;
                        sumHeight    = i * 35;
                    }
                }

                if (type == 1 && i == 5)
                {
                    monthInc += 5;
                }
                // Získání grafických objektů pro vykreslení na plátno - generuje je statická třída GRAPHIC
                (Rectangle left, Rectangle right, TextBlock name, TextBlock price) =
                    Graphic.BlueWhitePanel(names[i + monthInc], result[i].ToString(), new int[] { 200, 100 }, new int[] { heightChange, 22 }, new int[] { 3, 3 });
                // Přiřezení objektů na plátno
                canvas.Children.Add(left);
                canvas.Children.Add(right);
                canvas.Children.Add(name);
                canvas.Children.Add(price);
                // Vykreslení tmavě zeleného předělů v definovaných místech plátna
                if (i == 0 || i == 3 || i == 5)
                {
                    string[] splitNames = new string[] { "Základní informace", "Průměrné výdaje", "Týdení výdaje", "Měsíční výdaje" };
                    (Rectangle split_rectangle, TextBlock split_text) =
                        Graphic.SplitPanel(30, 425, 3, new SolidColorBrush(Color.FromArgb(255, 20, 82, 87)), splitNames[n]);
                    n++;
                    // Pro vykreslení ROKU - přeskočí název Týdenní výdaje a použije Měsíční výdaje
                    if (type == 1 && n == 2)
                    {
                        n++;
                    }

                    canvas.Children.Add(split_rectangle);
                    canvas.Children.Add(split_text);
                    // Tmavě zelený obdelník, který odděluje bloky
                    Canvas.SetLeft(split_rectangle, 5); Canvas.SetTop(split_rectangle, 8 + sumHeight + splitHeight);
                    // Popis předělovacího bloku - NADPIS SEKCE
                    Canvas.SetLeft(split_text, 150); Canvas.SetTop(split_text, 10 + sumHeight + splitHeight);
                    splitHeight += 35;
                }
                // Podmínka pro vykreslení datumů pro týdny
                if (type == 0 && i > 4)
                {
                    TextBlock weekDate = new TextBlock
                    {
                        FontSize   = 15,
                        FontWeight = FontWeights.Bold,
                        Foreground = Brushes.Black,
                        Text       = "- " + weeks[inc].ToShortDateString() + " - " + weeks[inc + 1].ToShortDateString()
                    };

                    canvas.Children.Add(weekDate);
                    Canvas.SetLeft(weekDate, 20); Canvas.SetTop(weekDate, 35 + sumHeight + splitHeight);
                    if (inc < result.Count - 1)
                    {
                        inc += 2;
                    }
                }

                // Obdelnik pod typem zůstatku -- Světle modrá
                Canvas.SetLeft(left, 10); Canvas.SetTop(left, 10 + sumHeight + splitHeight);
                // Obdelnik pod hodnotou zůstatku -- bílý
                Canvas.SetLeft(right, 230); Canvas.SetTop(right, 10 + sumHeight + splitHeight);
                // Typ zůstatku Bankovní účet nebo Hotovost
                Canvas.SetLeft(name, 15); Canvas.SetTop(name, 10 + sumHeight + splitHeight);
                // Hodnota zůstatku v dané platformě
                Canvas.SetLeft(price, 290); Canvas.SetTop(price, 10 + sumHeight + splitHeight);
            }
        }
Example #55
0
 /// <summary>
 /// Determines whether the specified month has value.
 /// </summary>
 /// <param name="month">The month.</param>
 /// <returns>True if has a value, false in otherwise</returns>
 public static bool HasValue(this Month month)
 {
     return(month != Month.NotSet);
 }
Example #56
0
        //http://www.smart.net/~mmontes/ushols.html#ALG
        internal static DateTime NthDayOfTheMonth(Week week, DayOfWeek weekDay, int year, Month month)
        {
            // 7*Q - 6 + (N - DoW(Year,Month,1))%7
            int x;

            switch (week)
            {
            case Week.Last:
                //NL = ND - (DoW(Year,Month,ND) - N)%7
                int nd    = DateTime.DaysInMonth(year, (int)month);
                int dow   = (int)DayOfWeek(new DateTime(year, (int)month, nd));
                int wd    = (int)weekDay;
                int dowwd = dow - wd;
                int mod   = dowwd % 7;
                if (dowwd < 0)
                {
                    mod = 7 + dowwd;
                }

                x = (nd) - (mod);
                break;

            default:
                int q = (int)week + 1;
                //x = 7 * (int)week - 6 + (weekDay - DayOfWeek(new DateTime(year, (int)month, 1)));
                x = (7 * q - 6) + (weekDay - DayOfWeek(new DateTime(year, (int)month, 1)));
                break;
            }

            if (x > DateTime.DaysInMonth(year, (int)month))
            {
                throw new ArgumentOutOfRangeException(string.Format("There is no {0} {1} in {2}.", week, weekDay, month));
            }

            return(new DateTime(year, (int)month, x));
        }
        public void op_ToMonth_DirectoryInfo()
        {
            using (var temp = new TempDirectory())
            {
                var file = temp.Info.ToDirectory("1969-03", true);

                var expected = new Month(1969, MonthOfYear.March);
                var actual = file.ToMonth();

                Assert.Equal(expected, actual);
            }
        }
Example #58
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["concat"]      = new Concat();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["search"]      = new Search();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     Functions["value"]       = new Value();
     Functions["trim"]        = new Trim();
     Functions["clean"]       = new Clean();
     Functions["unicode"]     = new Unicode();
     Functions["unichar"]     = new Unichar();
     Functions["numbervalue"] = new NumberValue();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["abs"]         = new Abs();
     Functions["asin"]        = new Asin();
     Functions["asinh"]       = new Asinh();
     Functions["cos"]         = new Cos();
     Functions["cosh"]        = new Cosh();
     Functions["power"]       = new Power();
     Functions["sign"]        = new Sign();
     Functions["sqrt"]        = new Sqrt();
     Functions["sqrtpi"]      = new SqrtPi();
     Functions["pi"]          = new Pi();
     Functions["product"]     = new Product();
     Functions["ceiling"]     = new Ceiling();
     Functions["count"]       = new Count();
     Functions["counta"]      = new CountA();
     Functions["countblank"]  = new CountBlank();
     Functions["countif"]     = new CountIf();
     Functions["countifs"]    = new CountIfs();
     Functions["fact"]        = new Fact();
     Functions["floor"]       = new Floor();
     Functions["sin"]         = new Sin();
     Functions["sinh"]        = new Sinh();
     Functions["sum"]         = new Sum();
     Functions["sumif"]       = new SumIf();
     Functions["sumifs"]      = new SumIfs();
     Functions["sumproduct"]  = new SumProduct();
     Functions["sumsq"]       = new Sumsq();
     Functions["stdev"]       = new Stdev();
     Functions["stdevp"]      = new StdevP();
     Functions["stdev.s"]     = new Stdev();
     Functions["stdev.p"]     = new StdevP();
     Functions["subtotal"]    = new Subtotal();
     Functions["exp"]         = new Exp();
     Functions["log"]         = new Log();
     Functions["log10"]       = new Log10();
     Functions["ln"]          = new Ln();
     Functions["max"]         = new Max();
     Functions["maxa"]        = new Maxa();
     Functions["median"]      = new Median();
     Functions["min"]         = new Min();
     Functions["mina"]        = new Mina();
     Functions["mod"]         = new Mod();
     Functions["average"]     = new Average();
     Functions["averagea"]    = new AverageA();
     Functions["averageif"]   = new AverageIf();
     Functions["averageifs"]  = new AverageIfs();
     Functions["round"]       = new Round();
     Functions["rounddown"]   = new Rounddown();
     Functions["roundup"]     = new Roundup();
     Functions["rand"]        = new Rand();
     Functions["randbetween"] = new RandBetween();
     Functions["rank"]        = new Rank();
     Functions["rank.eq"]     = new Rank();
     Functions["rank.avg"]    = new Rank(true);
     Functions["quotient"]    = new Quotient();
     Functions["trunc"]       = new Trunc();
     Functions["tan"]         = new Tan();
     Functions["tanh"]        = new Tanh();
     Functions["atan"]        = new Atan();
     Functions["atan2"]       = new Atan2();
     Functions["atanh"]       = new Atanh();
     Functions["acos"]        = new Acos();
     Functions["acosh"]       = new Acosh();
     Functions["var"]         = new Var();
     Functions["varp"]        = new VarP();
     Functions["large"]       = new Large();
     Functions["small"]       = new Small();
     Functions["degrees"]     = new Degrees();
     Functions["odd"]         = new Odd();
     Functions["even"]        = new Even();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     Functions["type"]       = new TypeFunction();
     // Logical
     Functions["if"]      = new If();
     Functions["ifs"]     = new Ifs();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     Functions["switch"]  = new Switch();
     // Reference and lookup
     Functions["address"]  = new Address();
     Functions["hlookup"]  = new HLookup();
     Functions["vlookup"]  = new VLookup();
     Functions["lookup"]   = new Lookup();
     Functions["match"]    = new Match();
     Functions["row"]      = new Row();
     Functions["rows"]     = new Rows();
     Functions["column"]   = new Column();
     Functions["columns"]  = new Columns();
     Functions["choose"]   = new Choose();
     Functions["index"]    = new RefAndLookup.Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset();
     // Date
     Functions["date"]             = new Date();
     Functions["today"]            = new Today();
     Functions["now"]              = new Now();
     Functions["day"]              = new Day();
     Functions["month"]            = new Month();
     Functions["year"]             = new Year();
     Functions["time"]             = new Time();
     Functions["hour"]             = new Hour();
     Functions["minute"]           = new Minute();
     Functions["second"]           = new Second();
     Functions["weeknum"]          = new Weeknum();
     Functions["weekday"]          = new Weekday();
     Functions["days"]             = new Days();
     Functions["days360"]          = new Days360();
     Functions["yearfrac"]         = new Yearfrac();
     Functions["edate"]            = new Edate();
     Functions["eomonth"]          = new Eomonth();
     Functions["isoweeknum"]       = new IsoWeekNum();
     Functions["workday"]          = new Workday();
     Functions["workday.intl"]     = new WorkdayIntl();
     Functions["networkdays"]      = new Networkdays();
     Functions["networkdays.intl"] = new NetworkdaysIntl();
     Functions["datevalue"]        = new DateValue();
     Functions["timevalue"]        = new TimeValue();
     // Database
     Functions["dget"]     = new Dget();
     Functions["dcount"]   = new Dcount();
     Functions["dcounta"]  = new DcountA();
     Functions["dmax"]     = new Dmax();
     Functions["dmin"]     = new Dmin();
     Functions["dsum"]     = new Dsum();
     Functions["daverage"] = new Daverage();
     Functions["dvar"]     = new Dvar();
     Functions["dvarp"]    = new Dvarp();
     //Finance
     Functions["pmt"] = new Pmt();
 }
Example #59
0
            public override bool isBusinessDay(Date date)
            {
                DayOfWeek w = date.DayOfWeek;
                int       d = date.Day, dd = date.DayOfYear;
                Month     m  = (Month)date.Month;
                int       y  = date.Year;
                int       em = easterMonday(y);

                if (isWeekend(w)
                    // Republic Day
                    || (d == 26 && m == Month.January)
                    // Good Friday
                    || (dd == em - 3)
                    // Ambedkar Jayanti
                    || (d == 14 && m == Month.April)
                    // Independence Day
                    || (d == 15 && m == Month.August)
                    // Gandhi Jayanti
                    || (d == 2 && m == Month.October)
                    // Christmas
                    || (d == 25 && m == Month.December)
                    )
                {
                    return(false);
                }

                if (y == 2005)
                {
                    // Moharram, Holi, Maharashtra Day, and Ramzan Id fall
                    // on Saturday or Sunday in 2005
                    if (// Bakri Id
                        (d == 21 && m == Month.January)
                        // Ganesh Chaturthi
                        || (d == 7 && m == Month.September)
                        // Dasara
                        || (d == 12 && m == Month.October)
                        // Laxmi Puja
                        || (d == 1 && m == Month.November)
                        // Bhaubeej
                        || (d == 3 && m == Month.November)
                        // Guru Nanak Jayanti
                        || (d == 15 && m == Month.November)
                        )
                    {
                        return(false);
                    }
                }

                if (y == 2006)
                {
                    if (// Bakri Id
                        (d == 11 && m == Month.January)
                        // Moharram
                        || (d == 9 && m == Month.February)
                        // Holi
                        || (d == 15 && m == Month.March)
                        // Ram Navami
                        || (d == 6 && m == Month.April)
                        // Mahavir Jayanti
                        || (d == 11 && m == Month.April)
                        // Maharashtra Day
                        || (d == 1 && m == Month.May)
                        // Bhaubeej
                        || (d == 24 && m == Month.October)
                        // Ramzan Id
                        || (d == 25 && m == Month.October)
                        )
                    {
                        return(false);
                    }
                }

                if (y == 2007)
                {
                    if (// Bakri Id
                        (d == 1 && m == Month.January)
                        // Moharram
                        || (d == 30 && m == Month.January)
                        // Mahashivratri
                        || (d == 16 && m == Month.February)
                        // Ram Navami
                        || (d == 27 && m == Month.March)
                        // Maharashtra Day
                        || (d == 1 && m == Month.May)
                        // Buddha Pournima
                        || (d == 2 && m == Month.May)
                        // Laxmi Puja
                        || (d == 9 && m == Month.November)
                        // Bakri Id (again)
                        || (d == 21 && m == Month.December)
                        )
                    {
                        return(false);
                    }
                }

                if (y == 2008)
                {
                    if (// Mahashivratri
                        (d == 6 && m == Month.March)
                        // Id-E-Milad
                        || (d == 20 && m == Month.March)
                        // Mahavir Jayanti
                        || (d == 18 && m == Month.April)
                        // Maharashtra Day
                        || (d == 1 && m == Month.May)
                        // Buddha Pournima
                        || (d == 19 && m == Month.May)
                        // Ganesh Chaturthi
                        || (d == 3 && m == Month.September)
                        // Ramzan Id
                        || (d == 2 && m == Month.October)
                        // Dasara
                        || (d == 9 && m == Month.October)
                        // Laxmi Puja
                        || (d == 28 && m == Month.October)
                        // Bhau bhij
                        || (d == 30 && m == Month.October)
                        // Gurunanak Jayanti
                        || (d == 13 && m == Month.November)
                        // Bakri Id
                        || (d == 9 && m == Month.December)
                        )
                    {
                        return(false);
                    }
                }

                if (y == 2009)
                {
                    if (// Moharram
                        (d == 8 && m == Month.January)
                        // Mahashivratri
                        || (d == 23 && m == Month.February)
                        // Id-E-Milad
                        || (d == 10 && m == Month.March)
                        // Holi
                        || (d == 11 && m == Month.March)
                        // Ram Navmi
                        || (d == 3 && m == Month.April)
                        // Mahavir Jayanti
                        || (d == 7 && m == Month.April)
                        // Maharashtra Day
                        || (d == 1 && m == Month.May)
                        // Ramzan Id
                        || (d == 21 && m == Month.September)
                        // Dasara
                        || (d == 28 && m == Month.September)
                        // Bhau Bhij
                        || (d == 19 && m == Month.October)
                        // Gurunanak Jayanti
                        || (d == 2 && m == Month.November)
                        // Moharram (again)
                        || (d == 28 && m == Month.December)
                        )
                    {
                        return(false);
                    }
                }

                if (y == 2010)
                {
                    if (// New Year's Day
                        (d == 1 && m == Month.January)
                        // Mahashivratri
                        || (d == 12 && m == Month.February)
                        // Holi
                        || (d == 1 && m == Month.March)
                        // Ram Navmi
                        || (d == 24 && m == Month.March)
                        // Ramzan Id
                        || (d == 10 && m == Month.September)
                        // Laxmi Puja
                        || (d == 5 && m == Month.November)
                        // Bakri Id
                        || (d == 17 && m == Month.November)
                        // Moharram
                        || (d == 17 && m == Month.December)
                        )
                    {
                        return(false);
                    }
                }



                return(true);
            }
Example #60
0
 public static DateTime LastDay(this Month month, int year)
 => month.FirstDay(year).MonthLastDay();