GetQuarterOfMonth() public static méthode

public static GetQuarterOfMonth ( YearMonth yearMonth ) : YearQuarter
yearMonth YearMonth
Résultat YearQuarter
        } // IsSameQuarter

        // ----------------------------------------------------------------------
        public static bool IsSameQuarter(YearMonth yearStartMonth, DateTime left, DateTime right)
        {
            int leftYear  = TimeTool.GetYearOf(yearStartMonth, left);
            int rightYear = TimeTool.GetYearOf(yearStartMonth, right);

            if (leftYear != rightYear)
            {
                return(false);
            }

            return(TimeTool.GetQuarterOfMonth(yearStartMonth, (YearMonth)left.Month) == TimeTool.GetQuarterOfMonth(yearStartMonth, (YearMonth)right.Month));
        } // IsSameQuarter
Exemple #2
0
        } // CalendarQuarter

        // ----------------------------------------------------------------------
        public static DateTime Quarter(YearMonth yearStartMonth)
        {
            DateTime now  = ClockProxy.Clock.Now;
            int      year = now.Year;

            if (now.Month - (int)yearStartMonth < 0)
            {
                year--;
            }
            YearQuarter quarter = TimeTool.GetQuarterOfMonth(yearStartMonth, (YearMonth)now.Month);
            int         months  = ((int)quarter - 1) * TimeSpec.MonthsPerQuarter;

            return(new DateTime(year, (int)yearStartMonth, 1).AddMonths(months));
        } // Quarter
Exemple #3
0
        } // CalcYears

        // ----------------------------------------------------------------------
        private int CalcQuarters()
        {
            if (TimeCompare.IsSameMonth(date1, date2))
            {
                return(0);
            }

            int         year1    = TimeTool.GetYearOf(yearBaseMonth, Year1, Month1);
            YearQuarter quarter1 = TimeTool.GetQuarterOfMonth(yearBaseMonth, (YearMonth)Month1);

            int         year2    = TimeTool.GetYearOf(yearBaseMonth, Year2, Month2);
            YearQuarter quarter2 = TimeTool.GetQuarterOfMonth(yearBaseMonth, (YearMonth)Month2);

            return(((year2 * TimeSpec.QuartersPerYear) + quarter2) -
                   ((year1 * TimeSpec.QuartersPerYear) + quarter1));
        } // CalcQuarters
        }                                          // Quarter

        // ----------------------------------------------------------------------
        public Quarter(DateTime moment, ITimeCalendar calendar) :
            this(TimeTool.GetYearOf(calendar.YearBaseMonth, calendar.GetYear(moment), calendar.GetMonth(moment)),
                 TimeTool.GetQuarterOfMonth(calendar.YearBaseMonth, (YearMonth)moment.Month), calendar)
        {
        }                                                                                                    // Quarter