Example #1
0
        // ----------------------------------------------------------------------
        public static void ShowAll( int periodCount, int year, YearMonth month, int day, int hour, int minuteValue )
        {
            WriteLine( "Input: count={0}, year={1}, month={2}, day={3}, hour={4}, minute={5}", periodCount, year, month, day, hour, minuteValue );
            WriteLine();

            if ( periodCount == 1 )
            {
                Minute minute = new Minute( year, (int)month, day, hour, minuteValue );
                Minute previousMinute = minute.GetPreviousMinute();
                Minute nextMinute = minute.GetNextMinute();

                ShowMinute( minute );
                ShowCompactMinute( previousMinute, "Previous Minute" );
                ShowCompactMinute( nextMinute, "Next Minute" );
                WriteLine();
            }
            else
            {
                Minutes minutes = new Minutes( year, (int)month, day, hour, minuteValue, periodCount );

                ShowMinutes( minutes );
                WriteLine();

                foreach ( Minute minute in minutes.GetMinutes() )
                {
                    ShowCompactMinute( minute );
                }
                WriteLine();
            }
        }
Example #2
0
 // ----------------------------------------------------------------------
 protected MonthTimeRange( int startYear, YearMonth startMonth, int monthCount, ITimeCalendar calendar )
     : base(GetPeriodOf( startYear, startMonth, monthCount ), calendar)
 {
     this.startYear = startYear;
     this.startMonth = startMonth;
     this.monthCount = monthCount;
     TimeTool.AddMonth( startYear, startMonth, monthCount - 1, out endYear, out endMonth );
 }
Example #3
0
        // ----------------------------------------------------------------------
        public static void AddMonth( int startYear, YearMonth startMonth, int count, out int year, out YearMonth month )
        {
            int offsetYear = ( Math.Abs( count ) / TimeSpec.MonthsPerYear ) + 1;
            int startMonthCount = ( ( startYear  + offsetYear ) * TimeSpec.MonthsPerYear ) + ( (int)startMonth - 1 );
            int targetMonthCount = startMonthCount + count;

            year = ( targetMonthCount / TimeSpec.MonthsPerYear ) - offsetYear;
            month = (YearMonth)( ( targetMonthCount % TimeSpec.MonthsPerYear ) + 1 );
        }
Example #4
0
 // ----------------------------------------------------------------------
 public MonthRange( YearMonth min, YearMonth max )
 {
     if ( max < min )
     {
         throw new ArgumentOutOfRangeException( "max" );
     }
     this.min = min;
     this.max = max;
 }
 public IndexPerformance(Index index, YearMonth yearMonth, decimal? @return, decimal? value)
 {
     Index = index;
     YearMonth = yearMonth;
     _month = yearMonth.Month;
     _year = yearMonth.Year;
     Return = @return;
     Value = value;
 }
Example #6
0
        // ----------------------------------------------------------------------
        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 );
        }
Example #7
0
 // ----------------------------------------------------------------------
 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 );
 }
Example #8
0
 // ----------------------------------------------------------------------
 public DateDiff( DateTime date1, DateTime date2, Calendar calendar,
     DayOfWeek firstDayOfWeek, YearMonth yearBaseMonth = TimeSpec.CalendarYearStartMonth)
 {
     if ( calendar == null )
     {
         throw new ArgumentNullException( "calendar" );
     }
     this.calendar = calendar;
     this.yearBaseMonth = yearBaseMonth;
     this.firstDayOfWeek = firstDayOfWeek;
     this.date1 = date1;
     this.date2 = date2;
     difference = date2.Subtract( date1 );
 }
Example #9
0
        // ----------------------------------------------------------------------
        public TimeCalendar( TimeCalendarConfig config )
        {
            if ( config.StartOffset < TimeSpan.Zero )
            {
                throw new ArgumentOutOfRangeException( "config" );
            }
            if ( config.EndOffset > TimeSpan.Zero )
            {
                throw new ArgumentOutOfRangeException( "config" );
            }

            culture = config.Culture ?? Thread.CurrentThread.CurrentCulture;
            yearType = config.YearType.HasValue ? config.YearType.Value : YearType.SystemYear;
            startOffset = config.StartOffset.HasValue ? config.StartOffset.Value : DefaultStartOffset;
            endOffset = config.EndOffset.HasValue ? config.EndOffset.Value : DefaultEndOffset;
            yearBaseMonth = config.YearBaseMonth.HasValue ? config.YearBaseMonth.Value : TimeSpec.CalendarYearStartMonth;
            yearWeekType = config.YearWeekType.HasValue ? config.YearWeekType.Value : YearWeekType.Calendar;
            dayNameType = config.DayNameType.HasValue ? config.DayNameType.Value : CalendarNameType.Full;
            monthNameType = config.MonthNameType.HasValue ? config.MonthNameType.Value : CalendarNameType.Full;
        }
Example #10
0
        // ----------------------------------------------------------------------
        public static void ShowAll( int periodCount, int year, YearMonth yearMonth, int dayValue )
        {
            WriteLine( "Input: count={0}, year={1}, month={2}, day={3}", periodCount, year, yearMonth, dayValue );
            WriteLine();

            DayTimeRange dayTimeRange;
            if ( periodCount == 1 )
            {
                Day day = new Day( year, (int)yearMonth, dayValue );
                dayTimeRange = day;

                Day previousDay = day.GetPreviousDay();
                Day nextDay = day.GetNextDay();

                ShowDay( day );
                ShowCompactDay( previousDay, "Previous Day" );
                ShowCompactDay( nextDay, "Next Day" );
                WriteLine();
            }
            else
            {
                Days days = new Days( year, (int)yearMonth, dayValue, periodCount );
                dayTimeRange = days;

                ShowDays( days );
                WriteLine();

                foreach ( Day day in days.GetDays() )
                {
                    ShowCompactDay( day );
                }
                WriteLine();
            }

            foreach ( Hour hour in dayTimeRange.GetHours() )
            {
                HourDemo.ShowCompactHour( hour );
            }
            WriteLine();
        }
Example #11
0
        // ----------------------------------------------------------------------
        public static void ShowAll( int periodCount, int year, YearMonth month, int day, int hourValue )
        {
            WriteLine( "Input: count={0}, year={1}, month={2}, day={3}, hour={4}", periodCount, year, month, day, hourValue );
            WriteLine();

            HourTimeRange hourTimeRange;
            if ( periodCount == 1 )
            {
                Hour hour = new Hour( year, (int)month, day, hourValue );
                hourTimeRange = hour;

                Hour previousHour = hour.GetPreviousHour();
                Hour nextHour = hour.GetNextHour();

                ShowHour( hour );
                ShowCompactHour( previousHour, "Previous Hour" );
                ShowCompactHour( nextHour, "Next Hour" );
                WriteLine();
            }
            else
            {
                Hours hours = new Hours( year, (int)month, day, hourValue, periodCount );
                hourTimeRange = hours;

                ShowHours( hours );
                WriteLine();

                foreach ( Hour hour in hours.GetHours() )
                {
                    ShowCompactHour( hour );
                }
                WriteLine();
            }

            foreach ( Minute minute in hourTimeRange.GetMinutes() )
            {
                MinuteDemo.ShowCompactMinute( minute );
            }
            WriteLine();
        }
Example #12
0
        // ----------------------------------------------------------------------
        public static void ShowAll( int periodCount, int year, YearMonth yearMonth )
        {
            WriteLine( "Input: count={0}, year={1}, month={2}", periodCount, year, yearMonth );
            WriteLine();

            MonthTimeRange monthTimeRange;
            if ( periodCount == 1 )
            {
                Month month = new Month( year, yearMonth );
                monthTimeRange = month;

                Month previousMonth = month.GetPreviousMonth();
                Month nextMonth = month.GetNextMonth();

                ShowMonth( month );
                ShowCompactMonth( previousMonth, "Previous Month" );
                ShowCompactMonth( nextMonth, "Next Month" );
                WriteLine();
            }
            else
            {
                Months months = new Months( year, yearMonth, periodCount );
                monthTimeRange = months;

                ShowMonths( months );
                WriteLine();

                foreach ( Month month in months.GetMonths() )
                {
                    ShowCompactMonth( month );
                }
                WriteLine();
            }

            foreach ( Day day in monthTimeRange.GetDays() )
            {
                DayDemo.ShowCompactDay( day );
            }
            WriteLine();
        }
Example #13
0
 // ----------------------------------------------------------------------
 public bool HasInside( YearMonth test )
 {
     return test >= min && test <= max;
 }
Example #14
0
 // ----------------------------------------------------------------------
 public MonthRange( YearMonth month )
     : this(month, month)
 {
 }
Example #15
0
 // ----------------------------------------------------------------------
 public static void AddMonth( YearMonth startMonth, int count, out int year, out YearMonth month )
 {
     AddMonth( 0, startMonth, count, out year, out month );
 }
Example #16
0
 // ----------------------------------------------------------------------
 public static void NextMonth( YearMonth startMonth, out int year, out YearMonth month )
 {
     AddMonth( startMonth, 1, out year, out month );
 }
Example #17
0
        private IborFutureTrade createTrade(LocalDate tradeDate, SecurityId securityId, double quantity, double notional, double price, YearMonth yearMonth, LocalDate lastTradeDate, LocalDate referenceDate)
        {
            double     accrualFactor = index.Tenor.get(ChronoUnit.MONTHS) / 12.0;
            IborFuture product       = IborFuture.builder().securityId(securityId).index(index).accrualFactor(accrualFactor).lastTradeDate(lastTradeDate).notional(notional).build();
            TradeInfo  info          = TradeInfo.of(tradeDate);

            return(IborFutureTrade.builder().info(info).product(product).quantity(quantity).price(price).build());
        }
Example #18
0
 // ----------------------------------------------------------------------
 protected MonthTimeRange( int startYear, YearMonth startMonth, int monthCounth )
     : this(startYear, startMonth, monthCounth, new TimeCalendar())
 {
 }
Example #19
0
 // ----------------------------------------------------------------------
 public static TimeCalendar New( TimeSpan startOffset, TimeSpan endOffset, YearMonth yearBaseMonth )
 {
     return new TimeCalendar( new TimeCalendarConfig
     {
         StartOffset = startOffset,
         EndOffset = endOffset,
         YearBaseMonth = yearBaseMonth,
     } );
 }
Example #20
0
        public void Equals_DifferentToNull()
        {
            YearMonth date = new YearMonth(2011, 1);

            Assert.IsFalse(date.Equals(null !));
        }
Example #21
0
        /// <summary>
        /// Save the Initial Budget object by splitting it into several object accordin to
        /// startYearMonth and endYearMonth values.
        /// </summary>
        /// <param name="startYearMonth">The startYearMonth value</param>
        /// <param name="endYearMonth">The endYearMonth value</param>
        private void SaveSplitted(YearMonth startYearMonth, YearMonth endYearMonth, InitialBudgetOtherCosts otherCosts, bool isAssociateCurrency, int associateCurrency, CurrencyConverter converter, AmountScaleOption scaleOption)
        {
            try
            {
                //Get the months difference
                int       monthsNo   = endYearMonth.GetMonthsDiffrence(startYearMonth) + 1;
                int[]     totalHours = Rounding.Divide(this.TotalHours, monthsNo);
                decimal[] sales      = Rounding.Divide(this.Sales, monthsNo);
                decimal[] valHours   = new decimal[monthsNo];
                if (this.ValuedHours != ApplicationConstants.DECIMAL_NULL_VALUE)
                {
                    valHours = Rounding.Divide(this.ValuedHours, monthsNo);
                }
                else
                {
                    for (int i = 0; i < monthsNo; i++)
                    {
                        valHours[i] = ApplicationConstants.DECIMAL_NULL_VALUE;
                    }
                }
                int[] detailsIds = new int[monthsNo];
                //Iterate through each month and construct the InitialBudget object
                for (YearMonth currentYearMonth = new YearMonth(startYearMonth.Value); currentYearMonth.Value <= endYearMonth.Value; currentYearMonth.AddMonths(1))
                {
                    //construct a new initial budget object
                    InitialBudget newBudget = new InitialBudget(this.CurrentConnectionManager);
                    newBudget.IdProject    = this.IdProject;
                    newBudget.IdPhase      = this.IdPhase;
                    newBudget.IdWP         = this.IdWP;
                    newBudget.IdCostCenter = this.IdCostCenter;
                    newBudget.IdAssociate  = this.IdAssociate;
                    newBudget.YearMonth    = currentYearMonth.Value;
                    newBudget.TotalHours   = totalHours[currentYearMonth.GetMonthsDiffrence(startYearMonth)];
                    newBudget.ValuedHours  = valHours[currentYearMonth.GetMonthsDiffrence(startYearMonth)];
                    newBudget.Sales        = sales[currentYearMonth.GetMonthsDiffrence(startYearMonth)];
                    if (this.State == EntityState.New)
                    {
                        newBudget.SetNew();
                    }
                    if (this.State == EntityState.Modified)
                    {
                        newBudget.SetModified();
                    }
                    if (this.State == EntityState.Deleted)
                    {
                        newBudget.SetDeleted();
                    }

                    //Apply the cost center currency if this is the case
                    if (isAssociateCurrency)
                    {
                        newBudget.ApplyCostCenterCurrency(associateCurrency, converter);
                    }
                    //Apply the amount scale
                    newBudget.ApplyAmountScaleOption(scaleOption);

                    //Saves the new budget
                    if (this.State == EntityState.New)
                    {
                        IdDetail = newBudget.Save();
                    }
                    else
                    {
                        newBudget.Save();
                    }
                }

                //Insert Other cost object
                if (otherCosts != null)
                {
                    otherCosts.SaveSplitted(startYearMonth, endYearMonth, isAssociateCurrency, this.IdCostCenter, associateCurrency, converter);
                }
            }
            catch (Exception exc)
            {
                throw new IndException(exc);
            }
        }
Example #22
0
        /// <summary>
        /// Saves the budget
        /// </summary>
        /// <param name="currentProject">The current project used</param>
        /// <param name="currentUser">The current logged user</param>
        /// <param name="FollowUpIdAssociate">The associate id if this is called from the follow up</param>
        /// <param name="otherCost">The other cost object associated with this budget</param>
        /// <param name="startYearMonth">The StartYearMonth</param>
        /// <param name="endYearMonth">the EndYearMonth</param>
        /// <param name="evidenceButtonVisible">Specify if the Submit button should be visible after this operation</param>
        public void InsertBudget(CurrentProject currentProject, CurrentUser currentUser, int FollowUpIdAssociate, InitialBudgetOtherCosts otherCost, YearMonth startYearMonth, YearMonth endYearMonth, out bool evidenceButtonVisible)
        {
            BeginTransaction();

            //Initialize the out paramter
            evidenceButtonVisible = false;

            try
            {
                //TODO: Call this method only if this is the case
                InsertMasterRecord();

                //Constructs a new FollowUpInitialBudget object
                FollowUpInitialBudget fIBudget = new FollowUpInitialBudget(this.CurrentConnectionManager);

                //Get the current budget state
                #region Get Current Budget State

                string budgetState = String.Empty;
                //Initialize the follow up buget object
                fIBudget.IdProject   = currentProject.Id;
                fIBudget.IdAssociate = ((FollowUpIdAssociate == ApplicationConstants.BUDGET_DIRECT_ACCESS ? ((currentUser.UserRole.Id == ApplicationConstants.ROLE_BUSINESS_ADMINISTATOR || currentUser.UserRole.Id == ApplicationConstants.ROLE_KEY_USER) && currentUser.IdImpersonatedAssociate > 0 ? currentUser.IdImpersonatedAssociate : currentUser.IdAssociate) : FollowUpIdAssociate));

                //Get the budget state
                DataSet dsButtons = fIBudget.GetInitialBudgetStateForEvidence("GetInitialBudgetStateForEvidence");
                //Find out the budget state from the dataset
                if (dsButtons != null)
                {
                    if (dsButtons.Tables[0].Rows.Count > 0)
                    {
                        budgetState = dsButtons.Tables[0].Rows[0]["StateCode"].ToString();
                    }
                    else
                    {
                        budgetState = ApplicationConstants.BUDGET_STATE_NONE;
                    }
                }
                else
                {
                    //Do not rollback here, exception will be caught later in this method
                    throw new IndException("This associate is not in CORETEAM");
                }
                #endregion Get Current Budget State
                //If the budget state is NONE than save it to OPEN
                if (budgetState == ApplicationConstants.BUDGET_STATE_NONE || budgetState == ApplicationConstants.BUDGET_STATE_UPLOADED)
                {
                    fIBudget.StateCode = ApplicationConstants.BUDGET_STATE_OPEN;
                    fIBudget.SetModified();
                    fIBudget.Save();

                    evidenceButtonVisible = true;
                }


                //Splits the budget into details and save them
                SaveSplitted(startYearMonth, endYearMonth, otherCost);

                CommitTransaction();
            }
            catch (Exception exc)
            {
                RollbackTransaction();
                throw new IndException(exc);
            }
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Creates an instance from an index, reference start month and reference end month.
 /// </summary>
 /// <param name="index">  the index </param>
 /// <param name="referenceStartMonth">  the reference start month </param>
 /// <param name="referenceEndMonth">  the reference end month </param>
 /// <returns> the inflation rate computation </returns>
 public static InflationMonthlyRateComputation of(PriceIndex index, YearMonth referenceStartMonth, YearMonth referenceEndMonth)
 {
     return(new InflationMonthlyRateComputation(PriceIndexObservation.of(index, referenceStartMonth), PriceIndexObservation.of(index, referenceEndMonth)));
 }
        public HouseholdBook CreateHouseholdBook()
        {
            var transactions = _transactionProvider.ProvideTransactions();

            var householdBook = new HouseholdBook();

            foreach (Banktransaction transaction in transactions.ToList())
            {
                var category      = _transactionCategorizer.DetermineCategory(transaction.Description);
                var householdPost = householdBook.RetrieveHouseholdPost(category);
                householdPost.AddTransaction(transaction.Description, transaction.Amount, YearMonth.FromDateTime(transaction.Date), transaction.TransactionDirection);
                transactions.Remove(transaction);
            }

            return(householdBook);
        }
Example #25
0
        public LocalDate calculateReferenceDateFromTradeDate(LocalDate tradeDate, YearMonth yearMonth, ReferenceData refData)
        {
            LocalDate referenceDate = dateSequence.dateMatching(yearMonth);

            return(businessDayAdjustment.adjust(referenceDate, refData));
        }
Example #26
0
 // ----------------------------------------------------------------------
 protected MonthTimeRange(int startYear, YearMonth startMonth, int monthCounth) :
     this(startYear, startMonth, monthCounth, new TimeCalendar())
 {
 }         // MonthTimeRange
Example #27
0
 private void setYearMonth(YearMonth value)
 {
     Context[typeof(YearMonth)] = value;
     Save();
 }
Example #28
0
        public void Equals_DifferentToOtherType()
        {
            YearMonth date = new YearMonth(2011, 1);

            Assert.IsFalse(date.Equals(Instant.FromUnixTimeTicks(0)));
        }
Example #29
0
 public int GetOneDayAmount()
 {
     return(Amount / DateTime.DaysInMonth(
                int.Parse(YearMonth.Substring(0, 4)),
                int.Parse((YearMonth.Substring(4, 2)))));
 }
Example #30
0
        }         // Month

        // ----------------------------------------------------------------------
        public Month(int year, YearMonth yearMonth) :
            this(year, yearMonth, new TimeCalendar())
        {
        }         // Month
Example #31
0
 // ----------------------------------------------------------------------
 public static DateTime Year( YearMonth yearStartMonth )
 {
     DateTime now = ClockProxy.Clock.Now;
     int startMonth = (int)yearStartMonth;
     int monthOffset = now.Month - startMonth;
     int year = monthOffset < 0 ? now.Year - 1 : now.Year;
     return new DateTime( year, startMonth, 1 );
 }
Example #32
0
        }         // Month

        // ----------------------------------------------------------------------
        public Month(int year, YearMonth yearMonth, ITimeCalendar calendar) :
            base(year, yearMonth, 1, calendar)
        {
        }         // Month
Example #33
0
 /// <summary>
 /// Sets the year-month of the expiry.
 /// <para>
 /// Expiry will occur on a date implied by the variant of the ETD.
 /// </para>
 /// </summary>
 /// <param name="expiry">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder expiry(YearMonth expiry)
 {
     JodaBeanUtils.notNull(expiry, "expiry");
     this.expiry_Renamed = expiry;
     return(this);
 }
Example #34
0
        } // GetStartOfHalfyear

        #endregion

        #region Year

        // ----------------------------------------------------------------------
        public static int GetFiscalYear(int calendarYear, YearMonth fiscalYearBaseMonth, YearMonth yearBaseMonth)
        {
            return(yearBaseMonth >= fiscalYearBaseMonth ? calendarYear + 1 : calendarYear);
        } // GetFiscalYear
Example #35
0
 // ----------------------------------------------------------------------
 public static void PreviousMonth( YearMonth startMonth, out int year, out YearMonth month )
 {
     AddMonth( startMonth, -1, out year, out month );
 }
Example #36
0
        } // GetDaysInMonth

        // ----------------------------------------------------------------------
        public static int GetYear(int year, YearMonth month, YearMonth yearBaseMonth, YearMonth fiscalYearBaseMonth)
        {
            year = yearBaseMonth >= fiscalYearBaseMonth ? year : year - 1;
            return((month - yearBaseMonth) < 0 ? year : year + 1);
        } // GetYear
Example #37
0
        } // DateDiff

        // ----------------------------------------------------------------------
        public DateDiff(DateTime date, Calendar calendar, DayOfWeek firstDayOfWeek,
                        YearMonth yearBaseMonth = TimeSpec.CalendarYearStartMonth) :
            this(date, ClockProxy.Clock.Now, calendar, firstDayOfWeek, yearBaseMonth)
        {
        } // DateDiff
        public void AddQuartersTest()
        {
            int             currentYear    = ClockProxy.Clock.Now.Year;
            const YearMonth yearStartMonth = YearMonth.April;
            TimeCalendar    calendar       = TimeCalendar.New(TimeSpan.Zero, TimeSpan.Zero, yearStartMonth);

            DateTime calendarStartDate = new DateTime(currentYear, 4, 1);
            Quarter  calendarQuarter   = new Quarter(currentYear, YearQuarter.First, calendar);

            Assert.AreEqual(calendarQuarter.AddQuarters(0), calendarQuarter);

            Quarter prevQ1 = calendarQuarter.AddQuarters(-1);

            Assert.AreEqual(prevQ1.YearQuarter, YearQuarter.Fourth);
            Assert.AreEqual(prevQ1.BaseYear, currentYear - 1);
            Assert.AreEqual(prevQ1.Start, calendarStartDate.AddMonths(-3));
            Assert.AreEqual(prevQ1.End, calendarStartDate);

            Quarter prevQ2 = calendarQuarter.AddQuarters(-2);

            Assert.AreEqual(prevQ2.YearQuarter, YearQuarter.Third);
            Assert.AreEqual(prevQ2.BaseYear, currentYear - 1);
            Assert.AreEqual(prevQ2.Start, calendarStartDate.AddMonths(-6));
            Assert.AreEqual(prevQ2.End, calendarStartDate.AddMonths(-3));

            Quarter prevQ3 = calendarQuarter.AddQuarters(-3);

            Assert.AreEqual(prevQ3.YearQuarter, YearQuarter.Second);
            Assert.AreEqual(prevQ3.BaseYear, currentYear - 1);
            Assert.AreEqual(prevQ3.Start, calendarStartDate.AddMonths(-9));
            Assert.AreEqual(prevQ3.End, calendarStartDate.AddMonths(-6));

            Quarter prevQ4 = calendarQuarter.AddQuarters(-4);

            Assert.AreEqual(prevQ4.YearQuarter, YearQuarter.First);
            Assert.AreEqual(prevQ4.BaseYear, currentYear - 1);
            Assert.AreEqual(prevQ4.Start, calendarStartDate.AddMonths(-12));
            Assert.AreEqual(prevQ4.End, calendarStartDate.AddMonths(-9));

            Quarter prevQ5 = calendarQuarter.AddQuarters(-5);

            Assert.AreEqual(prevQ5.YearQuarter, YearQuarter.Fourth);
            Assert.AreEqual(prevQ5.BaseYear, currentYear - 2);
            Assert.AreEqual(prevQ5.Start, calendarStartDate.AddMonths(-15));
            Assert.AreEqual(prevQ5.End, calendarStartDate.AddMonths(-12));

            Quarter futureQ1 = calendarQuarter.AddQuarters(1);

            Assert.AreEqual(futureQ1.YearQuarter, YearQuarter.Second);
            Assert.AreEqual(futureQ1.BaseYear, currentYear);
            Assert.AreEqual(futureQ1.Start, calendarStartDate.AddMonths(3));
            Assert.AreEqual(futureQ1.End, calendarStartDate.AddMonths(6));

            Quarter futureQ2 = calendarQuarter.AddQuarters(2);

            Assert.AreEqual(futureQ2.YearQuarter, YearQuarter.Third);
            Assert.AreEqual(futureQ2.BaseYear, currentYear);
            Assert.AreEqual(futureQ2.Start, calendarStartDate.AddMonths(6));
            Assert.AreEqual(futureQ2.End, calendarStartDate.AddMonths(9));

            Quarter futureQ3 = calendarQuarter.AddQuarters(3);

            Assert.AreEqual(futureQ3.YearQuarter, YearQuarter.Fourth);
            Assert.AreEqual(futureQ3.BaseYear, currentYear);
            Assert.AreEqual(futureQ3.Start, calendarStartDate.AddMonths(9));
            Assert.AreEqual(futureQ3.End, calendarStartDate.AddMonths(12));

            Quarter futureQ4 = calendarQuarter.AddQuarters(4);

            Assert.AreEqual(futureQ4.YearQuarter, YearQuarter.First);
            Assert.AreEqual(futureQ4.BaseYear, currentYear + 1);
            Assert.AreEqual(futureQ4.Start, calendarStartDate.AddMonths(12));
            Assert.AreEqual(futureQ4.End, calendarStartDate.AddMonths(15));

            Quarter futureQ5 = calendarQuarter.AddQuarters(5);

            Assert.AreEqual(futureQ5.YearQuarter, YearQuarter.Second);
            Assert.AreEqual(futureQ5.BaseYear, currentYear + 1);
            Assert.AreEqual(futureQ5.Start, calendarStartDate.AddMonths(15));
            Assert.AreEqual(futureQ5.End, calendarStartDate.AddMonths(18));
        }         // AddQuartersTest
 public AppointmentsForMonth(YearMonth month, AppointmentConfig config)
 {
     PrevMonthAvailable = config.AvailableIntervalStart == null || config.AvailableIntervalStart.Value.ToYearMonth() < month;
     NextMonthAvailable = config.AvailableIntervalEnd == null || month < config.AvailableIntervalEnd.Value.ToYearMonth();
     Month = month;
 }
Example #40
0
 public static TimeSpan Month(int year, YearMonth yearMonth)
 {
     return(DateTimeFormatInfo.CurrentInfo == null ? TimeSpan.Zero : Month(DateTimeFormatInfo.CurrentInfo.Calendar, year, yearMonth));
 }
Example #41
0
        // ----------------------------------------------------------------------
        private static TimeRange GetPeriodOf( YearMonth yearMonth, int startYear, YearHalfyear startHalfyear, int halfyearCount )
        {
            if ( halfyearCount < 1 )
            {
                throw new ArgumentOutOfRangeException( "halfyearCount" );
            }

            DateTime yearStart = new DateTime( startYear, (int)yearMonth, 1 );
            DateTime start = yearStart.AddMonths( ( (int)startHalfyear - 1 ) * TimeSpec.MonthsPerHalfyear );
            DateTime end = start.AddMonths( halfyearCount * TimeSpec.MonthsPerHalfyear );
            return new TimeRange( start, end );
        }
Example #42
0
 public static TimeSpan Month(Calendar calendar, int year, YearMonth yearMonth)
 {
     return(Days(calendar.GetDaysInMonth(year, (int)yearMonth)));
 }
Example #43
0
 // ----------------------------------------------------------------------
 public DateDiff( DateTime date, Calendar calendar, DayOfWeek firstDayOfWeek,
     YearMonth yearBaseMonth = TimeSpec.CalendarYearStartMonth)
     : this(date, ClockProxy.Clock.Now, calendar, firstDayOfWeek, yearBaseMonth)
 {
 }
Example #44
0
 // ----------------------------------------------------------------------
 public static TimeSpan Month( int year, YearMonth yearMonth )
 {
     return DateTimeFormatInfo.CurrentInfo == null ? TimeSpan.Zero : Month( DateTimeFormatInfo.CurrentInfo.Calendar, year, yearMonth );
 }
Example #45
0
 // ----------------------------------------------------------------------
 public static TimeCalendar New( YearMonth yearBaseMonth )
 {
     return new TimeCalendar( new TimeCalendarConfig
     {
         YearBaseMonth = yearBaseMonth
     } );
 }
Example #46
0
        // ----------------------------------------------------------------------
        private static TimeRange GetPeriodOf( YearMonth yearMonth, int year, YearQuarter yearQuarter, int quarterCount )
        {
            if ( quarterCount < 1 )
            {
                throw new ArgumentOutOfRangeException( "quarterCount" );
            }

            DateTime yearStart = new DateTime( year, (int)yearMonth, 1 );
            DateTime start = yearStart.AddMonths( ( (int)yearQuarter - 1 ) * TimeSpec.MonthsPerQuarter );
            DateTime end = start.AddMonths( quarterCount * TimeSpec.MonthsPerQuarter );
            return new TimeRange( start, end );
        }
Example #47
0
 // ----------------------------------------------------------------------
 public static TimeCalendar New( CultureInfo culture, YearMonth yearBaseMonth, YearWeekType yearWeekType )
 {
     return new TimeCalendar( new TimeCalendarConfig
     {
         Culture = culture,
         YearBaseMonth = yearBaseMonth,
         YearWeekType = yearWeekType
     } );
 }
Example #48
0
        } // DateDiff

        // ----------------------------------------------------------------------
        public DateDiff(TimeSpan difference, Calendar calendar,
                        DayOfWeek firstDayOfWeek, YearMonth yearBaseMonth = TimeSpec.CalendarYearStartMonth) :
            this(ClockProxy.Clock.Now, difference, calendar, firstDayOfWeek, yearBaseMonth)
        {
        } // DateDiff
Example #49
0
        // ----------------------------------------------------------------------
        private static TimeRange GetPeriodOf( int year, YearMonth yearMonth, int monthCount )
        {
            if ( monthCount < 1 )
            {
                throw new ArgumentOutOfRangeException( "monthCount" );
            }

            DateTime start = new DateTime( year, (int)yearMonth, 1 );
            DateTime end = start.AddMonths( monthCount );
            return new TimeRange( start, end );
        }
 public GroupedTransaction(decimal amount, YearMonth yearMonth, TransactionDirection transactionDirection)
 {
     Amount               = amount;
     YearMonth            = yearMonth;
     TransactionDirection = transactionDirection;
 }
Example #51
0
 public CalendarViewModel(YearMonth month, string?linkPage = null, Func <LocalDate, bool>?isDisable = null)
 {
     Month     = month;
     LinkPage  = linkPage;
     IsDisable = isDisable ?? (d => false);
 }
Example #52
0
 private EtdFutureSecurity(SecurityInfo info, EtdContractSpecId contractSpecId, YearMonth expiry, EtdVariant variant)
 {
     JodaBeanUtils.notNull(info, "info");
     JodaBeanUtils.notNull(contractSpecId, "contractSpecId");
     JodaBeanUtils.notNull(expiry, "expiry");
     JodaBeanUtils.notNull(variant, "variant");
     this.info           = info;
     this.contractSpecId = contractSpecId;
     this.expiry         = expiry;
     this.variant        = variant;
 }
Example #53
0
 // ----------------------------------------------------------------------
 public Months(DateTime moment, YearMonth startMonth, int count) :
     this(moment, startMonth, count, new TimeCalendar())
 {
 }         // Months
Example #54
0
        public IborFutureTrade createTrade(LocalDate tradeDate, SecurityId securityId, YearMonth yearMonth, double quantity, double notional, double price, ReferenceData refData)
        {
            LocalDate referenceDate = calculateReferenceDateFromTradeDate(tradeDate, yearMonth, refData);
            LocalDate lastTradeDate = index.calculateFixingFromEffective(referenceDate, refData);

            return(createTrade(tradeDate, securityId, quantity, notional, price, yearMonth, lastTradeDate, referenceDate));
        }
Example #55
0
 // ----------------------------------------------------------------------
 public static TimeSpan Month( Calendar calendar, int year, YearMonth yearMonth )
 {
     return Days( calendar.GetDaysInMonth( year, (int)yearMonth ) );
 }
Example #56
0
        }         // Months

        // ----------------------------------------------------------------------
        public Months(DateTime moment, YearMonth startMonth, int count, ITimeCalendar calendar) :
            this(calendar.GetYear(moment), startMonth, count, calendar)
        {
        }         // Months
Example #57
0
 // ----------------------------------------------------------------------
 public static bool IsSameYear( YearMonth yearStartMonth, DateTime left, DateTime right )
 {
     return TimeTool.GetYearOf( yearStartMonth, left ) == TimeTool.GetYearOf( yearStartMonth, right );
 }
Example #58
0
        }         // Months

        // ----------------------------------------------------------------------
        public Months(int startYear, YearMonth startMonth, int monthCounth) :
            this(startYear, startMonth, monthCounth, new TimeCalendar())
        {
        }         // Months
Example #59
0
			/// <summary>
			/// Initialize the structure with the current date, time and timezone
			/// </summary>
			public static ExsltDateTime ParseDate(string d)
			{
				// Try each potential class, from most specific to least specific.

				// First DateTimeTZ
				try
				{
					DateTimeTZ t = new DateTimeTZ(d);
					return t;
				}
				catch (FormatException)
				{
				}

				// Next Date
				try
				{
					DateTZ t = new DateTZ(d);
					return t;
				}
				catch (FormatException)
				{
				}

				// Next YearMonth
				try
				{
					YearMonth t = new YearMonth(d);
					return t;
				}
				catch (FormatException)
				{
				}

				// Finally Year -- don't catch the exception for the last type
				{
					YearTZ t = new YearTZ(d);
					return t;
				}
			}
Example #60
0
        }         // Months

        // ----------------------------------------------------------------------
        public Months(int startYear, YearMonth startMonth, int monthCount, ITimeCalendar calendar) :
            base(startYear, startMonth, monthCount, calendar)
        {
        }         // Months