Ejemplo n.º 1
0
        } // IsSameHalfyear

        // ----------------------------------------------------------------------
        public static bool IsSameHalfyear(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.GetHalfyearOfMonth(yearStartMonth, (YearMonth)left.Month) == TimeTool.GetHalfyearOfMonth(yearStartMonth, (YearMonth)right.Month));
        } // IsSameHalfyear
Ejemplo n.º 2
0
        } // CalendarHalfyear

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

            if (now.Month - (int)yearStartMonth < 0)
            {
                year--;
            }
            YearHalfyear halfyear = TimeTool.GetHalfyearOfMonth(yearStartMonth, (YearMonth)now.Month);
            int          months   = ((int)halfyear - 1) * TimeSpec.MonthsPerHalfyear;

            return(new DateTime(year, (int)yearStartMonth, 1).AddMonths(months));
        } // Halfyear
Ejemplo n.º 3
0
        } // Halfyear

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