GetDaysInMonth() public method

public GetDaysInMonth ( int year, int month, int era ) : int
year int
month int
era int
return int
コード例 #1
0
        [Test, Timeout(300000)] // Can take a long time under NCrunch.
        public void BclThroughHistory_Scriptural()
        {
            Calendar bcl = new HebrewCalendar();
            var noda = CalendarSystem.HebrewScriptural;

            // The min supported date/time starts part way through the year
            var minYear = bcl.GetYear(bcl.MinSupportedDateTime) + 1;
            // The max supported date/time ends part way through the year
            var maxYear = bcl.GetYear(bcl.MaxSupportedDateTime) - 1;

            // Can't use BclEquivalenceHelper for this one, because of the month conversions.
            for (int year = minYear; year <= maxYear; year++)
            {
                int months = bcl.GetMonthsInYear(year);
                Assert.AreEqual(months, noda.GetMonthsInYear(year));
                for (int civilMonth = 1; civilMonth <= months; civilMonth++)
                {
                    int scripturalMonth = HebrewMonthConverter.CivilToScriptural(year, civilMonth);
                    Assert.AreEqual(bcl.GetDaysInMonth(year, civilMonth), noda.GetDaysInMonth(year, scripturalMonth),
                        "Year: {0}; Month: {1} (civil)", year, civilMonth);
                    for (int day = 1; day < bcl.GetDaysInMonth(year, civilMonth); day++)
                    {
                        DateTime bclDate = new DateTime(year, civilMonth, day, bcl);
                        LocalDate nodaDate = new LocalDate(year, scripturalMonth, day, noda);
                        Assert.AreEqual(bclDate, nodaDate.AtMidnight().ToDateTimeUnspecified(), "{0}-{1}-{2}", year, scripturalMonth, day);
                        Assert.AreEqual(nodaDate, LocalDateTime.FromDateTime(bclDate, noda).Date);
                        Assert.AreEqual(year, nodaDate.Year);
                        Assert.AreEqual(scripturalMonth, nodaDate.Month);
                        Assert.AreEqual(day, nodaDate.Day);
                    }
                }
            }
        }
コード例 #2
0
ファイル: LinqTests.cs プロジェクト: ayahc1093/Zmanim
        public IEnumerable<ComplexZmanimCalendar> GetDaysInHebrewMonth(DateTime yearAndMonth, GeoLocation location)
        {
            Calendar calendar = new HebrewCalendar();
            var daysInMonth = calendar.GetDaysInMonth(calendar.GetYear(yearAndMonth), calendar.GetMonth(yearAndMonth));

            for (int i = 0; i < daysInMonth; i++)
            {
                var zmanimCalendar = new ComplexZmanimCalendar(location);
                zmanimCalendar.DateWithLocation.Date = new DateTime(yearAndMonth.Year, yearAndMonth.Month, i + 1);
                yield return zmanimCalendar;
            }
        }
コード例 #3
0
ファイル: LinqTests.cs プロジェクト: ayahc1093/Zmanim
        public IEnumerable<ComplexZmanimCalendar> GetDaysInHebrewYear(DateTime year, GeoLocation location)
        {
            Calendar calendar = new HebrewCalendar();
            var currentYear = calendar.GetYear(year);
            var amountOfMonths = calendar.GetMonthsInYear(currentYear);

            for (int i = 0; i < amountOfMonths; i++)
            {
                var currentMonth = i + 1;
                var daysInMonth = calendar.GetDaysInMonth(currentYear, currentMonth);

                for (int dayOfMonth = 0; dayOfMonth < daysInMonth; dayOfMonth++)
                {
                    var zmanimCalendar = new ComplexZmanimCalendar(location);
                    zmanimCalendar.DateWithLocation.Date = new DateTime(currentYear, currentMonth, dayOfMonth + 1, calendar);
                    yield return zmanimCalendar;
                }
            }
        }
コード例 #4
0
 public void DaysInMonth()
 {
     var bcl = new HebrewCalendar();
     // Not all months in the min/max years are supported
     var minYear = bcl.GetYear(bcl.MinSupportedDateTime) + 1;
     var maxYear = bcl.GetYear(bcl.MaxSupportedDateTime) - 1;
     
     for (int year = minYear; year <= maxYear; year++)
     {
         int months = bcl.GetMonthsInYear(year);
         for (int month = 1; month <= months; month++)
         {
             int scripturalMonth = HebrewMonthConverter.CivilToScriptural(year, month);
             int bclDays = bcl.GetDaysInMonth(year, month);
             int nodaDays = HebrewScripturalCalculator.DaysInMonth(year, scripturalMonth);
             Assert.AreEqual(bclDays, nodaDays);
         }
     }
 }
コード例 #5
0
ファイル: CalendarTest.cs プロジェクト: GirlD/mono
	[Test] // wrt bug #76252.
	public void HebrewCalendarGetDaysInMonth ()
	{
		HebrewCalendar c = new HebrewCalendar ();
		int year = c.GetYear (new DateTime (2005, 9, 1));
		Assert.AreEqual (5765, year);
		int days = c.GetDaysInMonth (year, 13, 1);
		Assert.AreEqual (29, days);
	}