public DateTimeFormatInfo()
 {
     // Construct an invariant culture DateTimeFormatInfo
     char[] comma = new char[] { ',' };
     mIsReadOnly = true;
     mAbbreviatedDayNames = "Sun,Mon,Tue,Wed,Thu,Fri,Sat".Split(comma);
     mAbbreviatedMonthGenitiveNames = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,".Split(comma);
     mAbbreviatedMonthNames = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,".Split(comma);
     mAMDesignator = "AM";
     mCalendarWeekRule = CalendarWeekRule.FirstDay;
     mDateSeparator = "/";
     mDayNames = "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".Split(comma);
     mFirstDayOfWeek = DayOfWeek.Sunday;
     mFullDateTimePattern = "dddd, dd MMMM yyyy HH:mm:ss";
     mLongDatePattern = "dddd, dd MMMM yyyy";
     mLongTimePattern = "HH:mm:ss";
     mMonthDayPattern = "MMMM dd";
     mMonthGenitiveNames = "January,February,March,April,May,June,July,August,September,October,November,December,".Split(comma);
     mMonthNames = "January,February,March,April,May,June,July,August,September,October,November,December,".Split(comma);
     mNativeCalendarName = "Gregorian Calendar";
     mPMDesignator = "PM";
     mRFC1123Pattern = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'";
     mShortDatePattern = "MM/dd/yyyy";
     mShortestDayNames = "Su,Mo,Tu,We,Th,Fr,Sa".Split(comma);
     mShortTimePattern = "HH:mm";
     mSortableDateTimePattern = "yyyy'-'MM'-'dd'T'HH':'mm':'ss";
     mTimeSeparator = ":";
     mUniversalSortableDateTimePattern = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'";
     mYearMonthPattern = "yyyy MMMM";
     mCalendar = new GregorianCalendar();
 }
Exemple #2
0
 public AuditoriumEvent(string name, Calendar calendar, Ring ring, Auditorium auditorium)
 {
     Name = name;
     Calendar = calendar;
     Ring = ring;
     Auditorium = auditorium;
 }
Exemple #3
0
 private void AddItemFromCalendar(Calendar calendar)
 {
     ListViewItem item = new ListViewItem();
     item.Tag = calendar;
     UpdateItemFromCalendar(item);
     calendarList.Items.Add(item);
 }
 /// <summary>
 /// Creates a new item with the specified date range and text
 /// </summary>
 /// <param name="calendar">Calendar to reference item</param>
 /// <param name="startDate">Start date of the item</param>
 /// <param name="endDate">End date of the item</param>
 /// <param name="text">Text of the item</param>
 public CalendarItem(Calendar calendar, DateTime startDate, DateTime endDate, string text)
     : this(calendar)
 {
     StartDate = startDate;
     EndDate = endDate;
     Text = text;
 }
Exemple #5
0
        public void simple_calendar_test()
        {
            // Arrange
            CalendarEventRequest cEvent = new CalendarEventRequest();
            cEvent.PRODID = "-//Microsoft Corporation//Outlook 14.0 MIMEDIR//EN";
            cEvent.DateStart = DateTime.Parse("7/26/2014 7:30AM").ToString("yyyyMMdd\\THHmmss");
            cEvent.DateEnd = DateTime.Parse("7/26/2014 11:30AM").ToString("yyyyMMdd\\THHmmss");
            cEvent.Description = "Important Reminders \n•	Please arrive at the course at least 30 minutes prior to Shotgun start time.\n•	CASH ONLY for payment of green fees and guest fees!!!\n•	Slow play is not permitted. Please be courteous to all golfers and keep on pace.\nIf you have any questions please contact either:\n•	[email protected] - 760-777-7090";
            cEvent.Location = "Classic Club Golf Course - Palm Desert";
            cEvent.Priority = 2;
            cEvent.Subject = "Classic Club Golf Course";
            cEvent.UID = "*****@*****.**";
            cEvent.Version = "1.0";
            cEvent.FileName = "Classic Club Golf Course";

            ICalendar simple = new SimpleCalendar(cEvent);

            Calendar calendar = new Calendar(simple);

            // Act
            calendar.Save();

            // Assert
            //Console.WriteLine(actual);
        }
 /// <summary>
 /// Copies the parameters from the specified <see cref="CalendarRendererEventArgs"/>
 /// </summary>
 /// <param name="original"></param>
 public CalendarRendererEventArgs(CalendarRendererEventArgs original)
 {
     _calendar = original.Calendar;
     _graphics = original.Graphics;
     _clip = original.ClipRectangle;
     _tag = original.Tag;
 }
 /// <summary>
 /// Creates a new <see cref="CalendarRendererEventArgs"/>
 /// </summary>
 /// <param name="calendar">Calendar where painting</param>
 /// <param name="g">Device where to paint</param>
 /// <param name="clip">Paint event clip area</param>
 public CalendarRendererEventArgs(Calendar calendar, Graphics g, Rectangle clipRectangle, object tag)
 {
     _calendar = calendar;
     _graphics = g;
     _clip = clipRectangle;
     _tag = tag;
 }
        public HttpResponseMessage PostCalendar(List<ApiCalendarModels> apiCalendars)
        {
            if (ModelState.IsValid)
            {
                var calendars = CalendarService.Get();

                foreach (var apiCalendar in apiCalendars)
                {
                    if (calendars.Any(c => c.ApiId == apiCalendar.Id))
                        continue;
                    
                    //Insert to database
                    var calendar = new Calendar
                    {
                        ApiId = apiCalendar.Id,
                        Attendee = apiCalendar.Attendee,
                        Body = apiCalendar.Body,
                        Subject = apiCalendar.Subject,
                        Date = apiCalendar.Date.HasValue ? apiCalendar.Date.Value.DateTime : (Nullable<DateTime>)null,
                        End = apiCalendar.End.HasValue ? apiCalendar.End.Value.DateTime : (Nullable<DateTime>)null
                    };

                    CalendarService.Insert(calendar);

                }

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created);
                //response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = calendar.Id }));
                return response;
            }
            else
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }
        }
 /// <summary>
 /// Konkstruktor. Tworzy kalendarz użytkownika, pozwalając na jego autoryzację.
 /// </summary>
 /// <param name="userName">Nazwa użytkownika.</param>
 /// <param name="uId">Id użytkownika.</param>
 public User(string userName, int uId)
 {
     UserEmail = userName;
     Logs.WriteErrorLog("Konstruktor USER, pole UserId: " + UserId.ToString());
     UserId = uId;
     Calendar = new Calendar(UserEmail, uId);
 }
Exemple #10
0
 public ZeroCouponBond(int settlementDays, Calendar calendar, double faceAmount, Date maturityDate, BusinessDayConvention paymentConvention, double redemption, Date issueDate)
     : base(settlementDays, calendar, issueDate)
 {
     maturityDate_ = maturityDate;
     Date redemptionDate = calendar_.adjust(maturityDate, paymentConvention);
     setSingleRedemption(faceAmount, redemption, redemptionDate);
 }
 public override object VisitCalendar(Calendar calendar)
 {
     if (!calendar.SupportsDataType(_currentDataType))
     {
         Report.AddError(calendar.Position, MessageFormat, "calendar", StringEnum.GetStringValue(_currentDataType));
     }
     return null;
 }
Exemple #12
0
 public Lesson(TeacherForDiscipline teacherForDiscipline, Calendar calendar,
               Ring ring, Auditorium auditorium)
 {
     TeacherForDiscipline = teacherForDiscipline;
     Calendar = calendar;
     Ring = ring;
     Auditorium = auditorium;
 }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _calendar = (Calendar)GetTemplateChild("Part_Calendar");
            _calendar.SelectedDatesChanged += Calendar_SelectedDatesChanged;
            _calendar.SelectedDate = Value ?? null;
        }
    protected override Control AddEditor(Control container)
    {
        Calendar datePicker = new Calendar();

        container.Controls.Add(datePicker);

        return datePicker;
    }
Exemple #15
0
 public YoYInflationLeg(Schedule schedule, Calendar cal, YoYInflationIndex index, Period observationLag)
 {
     schedule_ = schedule;
     index_ = index;
     observationLag_ = observationLag;
     paymentAdjustment_ = BusinessDayConvention.ModifiedFollowing;
     paymentCalendar_ = cal;
 }
Exemple #16
0
 public CalendarItem(CalendarItem lastItem)
 {
     // TODO: Complete member initialization
     this._owningCalendar = lastItem._owningCalendar;
     this.DayNumber = lastItem.DayNumber;
     this.EventsForDay = lastItem.EventsForDay;
     this.ItemDate = lastItem.ItemDate;
 }
 public static void AppendFacultyMeetingEvent(Calendar cal, Course course)
 {
     if (!course.FacultyMeetingUtc.HasValue) { return; }
     //CalendarMethods.Request is only valid for single event per calendar
     cal.Method = course.Cancelled ? CalendarMethods.Cancel : CalendarMethods.Publish;
     var courseEvent = cal.Events.First();
     var facultyMeet = CreateFacultyMeetingEvent(course);
     cal.Events.Add(facultyMeet);
 }
		public CalendarAdapter(Context c, Calendar monthCalendar) {

			month = monthCalendar;
			selectedDate = (Calendar)monthCalendar.Clone();
			mContext = c;
			month.Set(Calendar.DayOfMonth, 1);
			this.items = new ArrayList();
			refreshDays();
		}
 private static int GetExpectedFourDigitYear(Calendar calendar, int twoDigitYear)
 {
     int expectedFourDigitYear = calendar.TwoDigitYearMax - calendar.TwoDigitYearMax % 100 + twoDigitYear;
     if (expectedFourDigitYear > calendar.TwoDigitYearMax)
     {
         expectedFourDigitYear -= 100;
     }
     return expectedFourDigitYear;
 }
		public void TestInitialize ()
		{
			calendar = new Calendar ();
			calendar.Height = 200;
			calendar.Width = 200;
			DateTime date = new DateTime (2000, 2, 2);
			calendar.DisplayDate = date;
			calendar.SelectedDate = date;

		}
Exemple #21
0
        public void CalendarFirstMethod_test_3()
        {
            Calendar cal = new Calendar();
            GameObject gameObject = new GameObject();

            cal.AddEvent(2, gameObject, EventType.goDown);

            Event ev = cal.First(1);
            Assert.That(ev == null); // no event is supposed to be returned
        }
Exemple #22
0
        public void CalendarFirstMethod_test_4()
        {
            Calendar cal = new Calendar();
            GameObject gameObject = new GameObject();

            cal.AddEvent(1, gameObject, EventType.goDown);

            Event ev = cal.First(2);
            Assert.That(cal.CountOfEvents == 0);
        }
Exemple #23
0
        public void CalendarFirstMethod_test_1()
        {
            Calendar cal = new Calendar();
            GameObject gameObject = new GameObject();

            cal.AddEvent(1, gameObject, EventType.goDown);

            Event ev = cal.First(2);
            Assert.That(ev != null && ev.who == gameObject && ev.when == 1);
        }
        public ActionResult Create(Calendar calendar)
        {
            db.Calendar.Add(calendar);
            db.SaveChanges();

            var day = calendar.StartDate.Day;
            var month = calendar.StartDate.Month;
            var year = calendar.StartDate.Year;
            return Redirect("/Calendar/Index?Year=" + year + "&Month=" + month + "&Day=" + day);
        }
Exemple #25
0
 private static int MinCalendarYearInEra(Calendar calendar, int era)
 {
     int[] eras = calendar.Eras;
     Assert.InRange(era, 0, eras[0]);
     if (eras.Length == 1 || era == eras[eras.Length - 1] || era == 0)
     {
         return calendar.GetYear(calendar.MinSupportedDateTime);
     }
     return calendar.GetYear(calendar.ToDateTime(1, 1, 1, 0, 0, 0, 0, era));
 }
Exemple #26
0
        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="calendar"></param>
        /// <param name="timeRange"></param>
        /// <param name="previousCumulatedWorkInMinute"></param>
        public WorkTimeByRange(Calendar calendar, ITimePeriod timeRange, int previousCumulatedWorkInMinute)
            : base(calendar, timeRange.Start)
        {
            timeRange.ShouldNotBeNull("timeRange");
            Guard.Assert(timeRange.HasPeriod, @"timeRange는 명시적인 구간을 가져야 합니다.");

            TimePeriod.Setup(timeRange.Start, timeRange.End);

            CumulatedInMinute = previousCumulatedWorkInMinute + WorkInMinute;
        }
Exemple #27
0
        public void CalendarFirstMethod_test_6()
        {
            Calendar cal = new Calendar();
            GameObject gameObject = new GameObject();

            cal.IsEnabledAddingEvents = false;
            cal.AddEvent(2, gameObject, EventType.goDown);

            Assert.That(cal.CountOfEvents == 0);
        }
 public bool CreateCalendar(Calendar instance)
 {
     if (instance.ID == 0)
     {
         Db.Calendar.InsertOnSubmit(instance);
         Db.Calendar.Context.SubmitChanges();
         return true;
     }
     return false;
 }
Exemple #29
0
        public Business252(Calendar calendar)
        {
            if (calendar == null)
            {
                throw new ArgumentNullException("calendar");
            }

            _calendar = calendar;
            DayCounterImplementation = this;
        }
Exemple #30
0
 private static int MaxGregorianYearInEra(Calendar calendar, int era)
 {
     int[] eras = calendar.Eras;
     Assert.InRange(era, 0, eras[0]);
     if (eras.Length == 1 || era == eras[0] || era == 0)
     {
         return calendar.MaxSupportedDateTime.Year;
     }
     return (calendar.ToDateTime(1, 1, 1, 0, 0, 0, 0, era + 1).AddDays(-1)).Year;
 }
 public static DateTime April(this int @this, int year, Calendar calendar)
 => new DateTime(year, APRIL, @this, calendar);
Exemple #32
0
 public void setConventions()
 {
     calendar   = new TARGET();
     optionBdc  = BusinessDayConvention.ModifiedFollowing;
     dayCounter = new Actual365Fixed();
 }
 private static ICalendar UnserializeCalendar(string s) => Calendar.LoadFromStream(new StringReader(s)).Single();
Exemple #34
0
        private void calendar_Click(object sender, EventArgs e)
        {
            Calendar c = new Calendar();

            c.ShowDialog();
        }
Exemple #35
0
 public CPIBond(uint settlementDays, double faceAmount, bool growthOnly, double baseCPI, Period observationLag, ZeroInflationIndex cpiIndex, CPI.InterpolationType observationInterpolation, Schedule schedule, DoubleVector coupons, DayCounter accrualDayCounter, BusinessDayConvention paymentConvention, Date issueDate, Calendar paymentCalendar) : this(NQuantLibcPINVOKE.new_CPIBond__SWIG_4(settlementDays, faceAmount, growthOnly, baseCPI, Period.getCPtr(observationLag), ZeroInflationIndex.getCPtr(cpiIndex), (int)observationInterpolation, Schedule.getCPtr(schedule), DoubleVector.getCPtr(coupons), DayCounter.getCPtr(accrualDayCounter), (int)paymentConvention, Date.getCPtr(issueDate), Calendar.getCPtr(paymentCalendar)), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
        static void Main()
        {
            #region initializing all necessary objects
            GoodsController goodsController = new GoodsController();

            Greetings();
            var userController  = new UserController();
            var orderController = new OrderController();

            var storage  = new Storage();
            var calendar = new Calendar();


            ChangeUser(userController, orderController);

            calendar.NewDay += storage.GetItemsFromProvider;
            calendar.NewDay += storage.CheckOrders;
            calendar.NewDay += orderController.CheckOrders;

            #endregion

            while (true)
            {
                Console.Write("Type any key to move to the menu . . .");
                Console.ReadKey();
                Console.Clear();
                Console.WriteLine("Day today: " + calendar.GetDayOfWeek() + "\n");
                Menu();
                ChooseLimits(1, 6, "Type your option: ", out int choose);
                Console.WriteLine();
                switch (choose)
                {
                case (1):
                    ChangeUser(userController, orderController);
                    break;

                case (2):
                    MakeOrder(orderController, storage);
                    break;

                case (3):
                    if (orderController.CurrentOrder.IsSent)
                    {
                        Console.WriteLine($"You are on {storage.GetQueuePosition(orderController.CurrentOrder.CurrentUser)} position in queue.");
                    }
                    else
                    {
                        Console.WriteLine("Unsent order.");
                    }
                    PrintBasket(orderController.CurrentOrder.Basket);
                    break;

                case (4):
                    PrintBasket(orderController.CurrentBasket);
                    break;

                case (5):
                    calendar.MoveOneDay();
                    break;

                case (6):
                    return;
                }
            }
        }
 public void Should_Throw_On_Invalid_Literal(string input)
 {
     Assert.Throws <ArgumentException>(() => Calendar.ParseAsLiteral(input));
 }
        public void Should_Convert_To_Local_Time_Zone()
        {
            var swedishTime = Calendar.Now(TimeZones.Sweden);

            swedishTime.Should().BeAfter(DateTime.UtcNow);
        }
Exemple #39
0
        public void testConventions()
        {
            // Testing business day conventions...

            SingleCase[] testCases =
            {
                // Following
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Following,                  new Date(3,  Month.February, 2015), new Period(1,  TimeUnit.Months), false, new Date(3,  Month.March,    2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Following,                  new Date(3,  Month.February, 2015), new Period(4,  TimeUnit.Days),   false, new Date(9,  Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Following,                  new Date(31, Month.January,  2015), new Period(1,  TimeUnit.Months), true,  new Date(27, Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Following,                  new Date(31, Month.January,  2015), new Period(1,  TimeUnit.Months), false, new Date(2,  Month.March,    2015)),

                //ModifiedFollowing
                new SingleCase(new SouthAfrica(), BusinessDayConvention.ModifiedFollowing,          new Date(3,  Month.February, 2015), new Period(1,  TimeUnit.Months), false, new Date(3,  Month.March,    2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.ModifiedFollowing,          new Date(3,  Month.February, 2015), new Period(4,  TimeUnit.Days),   false, new Date(9,  Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.ModifiedFollowing,          new Date(31, Month.January,  2015), new Period(1,  TimeUnit.Months), true,  new Date(27, Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.ModifiedFollowing,          new Date(31, Month.January,  2015), new Period(1,  TimeUnit.Months), false, new Date(27, Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.ModifiedFollowing,          new Date(25, Month.March,    2015), new Period(1,  TimeUnit.Months), false, new Date(28, Month.April,    2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.ModifiedFollowing,          new Date(7,  Month.February, 2015), new Period(1,  TimeUnit.Months), false, new Date(9,  Month.March,    2015)),

                //Preceding
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Preceding,                  new Date(3,  Month.March,    2015), new Period(-1, TimeUnit.Months), false, new Date(3,  Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Preceding,                  new Date(3,  Month.February, 2015), new Period(-2, TimeUnit.Days),   false, new Date(30, Month.January,  2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Preceding,                  new Date(1,  Month.March,    2015), new Period(-1, TimeUnit.Months), true,  new Date(30, Month.January,  2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Preceding,                  new Date(1,  Month.March,    2015), new Period(-1, TimeUnit.Months), false, new Date(30, Month.January,  2015)),

                //ModifiedPreceding
                new SingleCase(new SouthAfrica(), BusinessDayConvention.ModifiedPreceding,          new Date(3,  Month.March,    2015), new Period(-1, TimeUnit.Months), false, new Date(3,  Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.ModifiedPreceding,          new Date(3,  Month.February, 2015), new Period(-2, TimeUnit.Days),   false, new Date(30, Month.January,  2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.ModifiedPreceding,          new Date(1,  Month.March,    2015), new Period(-1, TimeUnit.Months), true,  new Date(2,  Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.ModifiedPreceding,          new Date(1,  Month.March,    2015), new Period(-1, TimeUnit.Months), false, new Date(2,  Month.February, 2015)),

                //Unadjusted
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Unadjusted,                 new Date(3,  Month.February, 2015), new Period(1,  TimeUnit.Months), false, new Date(3,  Month.March,    2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Unadjusted,                 new Date(3,  Month.February, 2015), new Period(4,  TimeUnit.Days),   false, new Date(9,  Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Unadjusted,                 new Date(31, Month.January,  2015), new Period(1,  TimeUnit.Months), true,  new Date(27, Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Unadjusted,                 new Date(31, Month.January,  2015), new Period(1,  TimeUnit.Months), false, new Date(28, Month.February, 2015)),

                //HalfMonthModifiedFollowing
                new SingleCase(new SouthAfrica(), BusinessDayConvention.HalfMonthModifiedFollowing, new Date(3,  Month.February, 2015), new Period(1,  TimeUnit.Months), false, new Date(3,  Month.March,    2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.HalfMonthModifiedFollowing, new Date(3,  Month.February, 2015), new Period(4,  TimeUnit.Days),   false, new Date(9,  Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.HalfMonthModifiedFollowing, new Date(31, Month.January,  2015), new Period(1,  TimeUnit.Months), true,  new Date(27, Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.HalfMonthModifiedFollowing, new Date(31, Month.January,  2015), new Period(1,  TimeUnit.Months), false, new Date(27, Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.HalfMonthModifiedFollowing, new Date(3,  Month.January,  2015), new Period(1,  TimeUnit.Weeks),  false, new Date(12, Month.January,  2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.HalfMonthModifiedFollowing, new Date(21, Month.March,    2015), new Period(1,  TimeUnit.Weeks),  false, new Date(30, Month.March,    2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.HalfMonthModifiedFollowing, new Date(7,  Month.February, 2015), new Period(1,  TimeUnit.Months), false, new Date(9,  Month.March,    2015)),

                //Nearest
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Nearest,                    new Date(3,  Month.February, 2015), new Period(1,  TimeUnit.Months), false, new Date(3,  Month.March,    2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Nearest,                    new Date(3,  Month.February, 2015), new Period(4,  TimeUnit.Days),   false, new Date(9,  Month.February, 2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Nearest,                    new Date(16, Month.April,    2015), new Period(1,  TimeUnit.Months), false, new Date(15, Month.May,      2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Nearest,                    new Date(17, Month.April,    2015), new Period(1,  TimeUnit.Months), false, new Date(18, Month.May,      2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Nearest,                    new Date(4,  Month.March,    2015), new Period(1,  TimeUnit.Months), false, new Date(2,  Month.April,    2015)),
                new SingleCase(new SouthAfrica(), BusinessDayConvention.Nearest,                    new Date(2,  Month.April,    2015), new Period(1,  TimeUnit.Months), false, new Date(4,  Month.May, 2015))
            };

            int n = testCases.Length;

            for (int i = 0; i < n; i++)
            {
                Calendar calendar = new Calendar(testCases[i].calendar);
                Date     result   = calendar.advance(testCases[i].start, testCases[i].period, testCases[i].convention, testCases[i].endOfMonth);

                QAssert.IsTrue(result == testCases[i].result,
                               "\ncase " + i + ":\n" //<< j << " ("<< desc << "): "
                               + "start date: " + testCases[i].start + "\n"
                               + "calendar: " + calendar + "\n"
                               + "period: " + testCases[i].period + ", end of month: " + testCases[i].endOfMonth + "\n"
                               + "convention: " + testCases[i].convention + "\n"
                               + "expected: " + testCases[i].result + " vs. actual: " + result);
            }
        }
Exemple #40
0
 public Schedule(Date effectiveDate, Date terminationDate, Period tenor, Calendar calendar, BusinessDayConvention convention, BusinessDayConvention terminationDateConvention, DateGeneration.Rule rule, bool endOfMonth) : this(NQuantLibcPINVOKE.new_Schedule__SWIG_3(Date.getCPtr(effectiveDate), Date.getCPtr(terminationDate), Period.getCPtr(tenor), Calendar.getCPtr(calendar), (int)convention, (int)terminationDateConvention, (int)rule, endOfMonth), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemple #41
0
 public Schedule(DateVector arg0, Calendar calendar, BusinessDayConvention rollingConvention) : this(NQuantLibcPINVOKE.new_Schedule__SWIG_0(DateVector.getCPtr(arg0), Calendar.getCPtr(calendar), (int)rollingConvention), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
        /// <summary>
        /// Returns the week of the year
        /// </summary>
        public static int GetWeekOfYear(DateTime date, CalendarWeekRule calendarWeekRule, DayOfWeek firstDayOfWeek)
        {
            Calendar calendar = CultureInfo.CurrentCulture.Calendar;

            return(calendar.GetWeekOfYear(date, calendarWeekRule, firstDayOfWeek));
        }
Exemple #43
0
 public static IDateTimeYearBuilder calendar(
     this IDateTimeCalendarBuilder that,
     Calendar calendar) => that.Calendar(calendar);
Exemple #44
0
        //Validate against china money announcement
        //http://www.chinamoney.com.cn/fe/Channel/10325

        //[TestMethod]
        public void ValidateCalendarAgainstChinaMoney()
        {
            var cmHolidays = GetChinaMoneyHoliday();
            var Calendars  = Enum.GetValues(typeof(Calendar));

            var calToFix = new List <Calendar>();

            foreach (Calendar Calendar in Calendars)
            {
                var calendar = CalendarImpl.Get(Calendar);
                if (Calendar == Calendar.Chn)
                {
                    continue;
                }

                var holToValidate = cmHolidays[Calendar];
                foreach (var d in holToValidate)
                {
                    if (!calendar.IsHoliday(d))
                    {
                        Console.WriteLine("date {0} should be holiday but is not in calendar {1}", d, Calendar);
                        calToFix.Add(Calendar);
                    }
                }
                var years   = holToValidate.Select(x => x.Year).Distinct().OrderBy(x => x);
                var date    = new Date(years.First(), 01, 01);
                var incTerm = new Term("1D");

                while (date < new Date(years.Last(), 12, 31))
                {
                    if (calendar.IsHoliday(date) && !date.IsWeekend && !holToValidate.Contains(date))
                    {
                        Console.WriteLine("date {0} is holiday in calendar {1} but should not be", date, Calendar);
                        calToFix.Add(Calendar);
                    }
                    date = incTerm.Next(date);
                }


                Console.WriteLine();
                Console.WriteLine();
            }

            calToFix = calToFix.Distinct().ToList();
            var outputFolder = @"D:\fixedCalendar\";

            foreach (var Calendar in calToFix)
            {
                var outputFile = outputFolder + Calendar.ToString().ToLower() + ".txt";
                var file       = new StreamWriter(File.Open(outputFile, FileMode.Create));
                file.WriteLine("{");
                file.WriteLine(@"""HolidayList"":[");
                var incTerm = new Term("1D");

                var calendar      = CalendarImpl.Get(Calendar);
                var holToValidate = cmHolidays[Calendar];
                var years         = holToValidate.Select(x => x.Year).Distinct().ToDictionary(x => x, x => x);

                for (var date = _begDate; date <= _endDate;)
                {
                    if (calendar.IsHoliday(date))
                    {
                        if (years.ContainsKey(date.Year) && !date.IsWeekend && !holToValidate.Contains(date))
                        {
                        }
                        else
                        {
                            file.WriteLine(@"""" + date.Year + "," + date.Month.ToString("0#") + "," + date.Day.ToString("0#") + @"""" + ",");
                        }
                    }
                    else
                    {
                        if (holToValidate.Contains(date))
                        {
                            file.WriteLine(@"""" + date.Year + "," + date.Month.ToString("0#") + "," + date.Day.ToString("0#") + @"""" + ",");
                        }
                    }

                    date = incTerm.Next(date);
                }


                file.WriteLine("]");
                file.WriteLine("}");
                file.Close();
            }
        }
Exemple #45
0
        public void Merge1()
        {
            var iCal1 = Calendar.LoadFromStream(new StringReader(IcsFiles.MonthlyCountByMonthDay3))[0];
            var iCal2 = Calendar.LoadFromStream(new StringReader(IcsFiles.MonthlyByDay1))[0];

            // Change the UID of the 2nd event to make sure it's different
            iCal2.Events[iCal1.Events[0].Uid].Uid = "1234567890";
            iCal1.MergeWith(iCal2);

            var evt1 = iCal1.Events.First();
            var evt2 = iCal1.Events.Skip(1).First();

            // Get occurrences for the first event
            var occurrences = evt1.GetOccurrences(
                new CalDateTime(1996, 1, 1, _tzid),
                new CalDateTime(2000, 1, 1, _tzid)).OrderBy(o => o.Period.StartTime).ToList();

            var dateTimes = new[]
            {
                new CalDateTime(1997, 9, 10, 9, 0, 0, _tzid),
                new CalDateTime(1997, 9, 11, 9, 0, 0, _tzid),
                new CalDateTime(1997, 9, 12, 9, 0, 0, _tzid),
                new CalDateTime(1997, 9, 13, 9, 0, 0, _tzid),
                new CalDateTime(1997, 9, 14, 9, 0, 0, _tzid),
                new CalDateTime(1997, 9, 15, 9, 0, 0, _tzid),
                new CalDateTime(1999, 3, 10, 9, 0, 0, _tzid),
                new CalDateTime(1999, 3, 11, 9, 0, 0, _tzid),
                new CalDateTime(1999, 3, 12, 9, 0, 0, _tzid),
                new CalDateTime(1999, 3, 13, 9, 0, 0, _tzid)
            };

            var timeZones = new[]
            {
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern"
            };

            for (var i = 0; i < dateTimes.Length; i++)
            {
                IDateTime dt    = dateTimes[i];
                var       start = occurrences[i].Period.StartTime;
                Assert.AreEqual(dt, start);

                var expectedZone = DateUtil.GetZone(dt.TimeZoneName);
                var actualZone   = DateUtil.GetZone(timeZones[i]);

                //Assert.AreEqual();

                //Normalize the time zones and then compare equality
                Assert.AreEqual(expectedZone, actualZone);

                //Assert.IsTrue(dt.TimeZoneName == TimeZones[i], "Event " + dt + " should occur in the " + TimeZones[i] + " timezone");
            }

            Assert.IsTrue(occurrences.Count == dateTimes.Length, "There should be exactly " + dateTimes.Length + " occurrences; there were " + occurrences.Count);

            // Get occurrences for the 2nd event
            occurrences = evt2.GetOccurrences(
                new CalDateTime(1996, 1, 1, _tzid),
                new CalDateTime(1998, 4, 1, _tzid)).OrderBy(o => o.Period.StartTime).ToList();

            var dateTimes1 = new[]
            {
                new CalDateTime(1997, 9, 2, 9, 0, 0, _tzid),
                new CalDateTime(1997, 9, 9, 9, 0, 0, _tzid),
                new CalDateTime(1997, 9, 16, 9, 0, 0, _tzid),
                new CalDateTime(1997, 9, 23, 9, 0, 0, _tzid),
                new CalDateTime(1997, 9, 30, 9, 0, 0, _tzid),
                new CalDateTime(1997, 11, 4, 9, 0, 0, _tzid),
                new CalDateTime(1997, 11, 11, 9, 0, 0, _tzid),
                new CalDateTime(1997, 11, 18, 9, 0, 0, _tzid),
                new CalDateTime(1997, 11, 25, 9, 0, 0, _tzid),
                new CalDateTime(1998, 1, 6, 9, 0, 0, _tzid),
                new CalDateTime(1998, 1, 13, 9, 0, 0, _tzid),
                new CalDateTime(1998, 1, 20, 9, 0, 0, _tzid),
                new CalDateTime(1998, 1, 27, 9, 0, 0, _tzid),
                new CalDateTime(1998, 3, 3, 9, 0, 0, _tzid),
                new CalDateTime(1998, 3, 10, 9, 0, 0, _tzid),
                new CalDateTime(1998, 3, 17, 9, 0, 0, _tzid),
                new CalDateTime(1998, 3, 24, 9, 0, 0, _tzid),
                new CalDateTime(1998, 3, 31, 9, 0, 0, _tzid)
            };

            var timeZones1 = new[]
            {
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern",
                "US-Eastern"
            };

            for (var i = 0; i < dateTimes1.Length; i++)
            {
                IDateTime dt    = dateTimes1[i];
                var       start = occurrences[i].Period.StartTime;
                Assert.AreEqual(dt, start);
                Assert.IsTrue(dt.TimeZoneName == timeZones1[i], "Event " + dt + " should occur in the " + timeZones1[i] + " timezone");
            }

            Assert.AreEqual(dateTimes1.Length, occurrences.Count, "There should be exactly " + dateTimes1.Length + " occurrences; there were " + occurrences.Count);
        }
Exemple #46
0
 //! floating reference date, fixed market data
 public ConstantOptionletVolatility(int settlementDays, Calendar cal, BusinessDayConvention bdc,
                                    double vol, DayCounter dc)
     : base(settlementDays, cal, bdc, dc)
 {
     volatility_ = new Handle <Quote>(new SimpleQuote(vol));
 }
        public FileResult Index(Guid?Id)
        {
            if (Id == null)
            {
                return(AccessDenied());
            }

            RemoteCalendarAccessManager manager = new RemoteCalendarAccessManager();

            BLM.RemoteCalendarAccess remoteCalendarAccess = manager.GetRemoteCalendarAccess(Id.Value);

            if (remoteCalendarAccess == null)
            {
                return(AccessDenied());
            }

            AzureActiveDirectory azureAD = new AzureActiveDirectory();

            IUser user = null;

            try
            {
                user = azureAD.GetUser(remoteCalendarAccess.UserId).Result;
            }
            catch (AggregateException e)
            {
                if (!e.InnerExceptions.Any(i => i.Message == "User " + remoteCalendarAccess.UserId + " not found."))
                {
                    throw;
                }
            }

            if (user == null || user.AccountEnabled == false)
            {
                return(AccessDenied());
            }

            manager.UpdateLastAccessTime(remoteCalendarAccess);

            Uri           uri           = new Uri(remoteCalendarAccess.SiteAddress);
            string        realm         = TokenHelper.GetRealmFromTargetUrl(uri);
            var           token         = TokenHelper.GetAppOnlyAccessToken("00000003-0000-0ff1-ce00-000000000000", uri.Authority, realm);
            ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken(uri.ToString(), token.AccessToken);

            clientContext.Load(clientContext.Web.Lists);
            clientContext.ExecuteQuery();

            List list = clientContext.Web.Lists.Where(l => l.Id == remoteCalendarAccess.CalendarId).First();

            if (list == null)
            {
                return(AccessDenied());
            }

            ListItemCollection items = list.GetItems(CamlQuery.CreateAllItemsQuery());

            clientContext.Load(items);

            clientContext.Load(clientContext.Web);
            clientContext.Load(clientContext.Web.RegionalSettings);
            clientContext.Load(clientContext.Web.RegionalSettings.TimeZone);
            clientContext.Load(clientContext.Web, w => w.Title);

            clientContext.ExecuteQuery();

            Calendar calendar = new Calendar();

            calendar.Title    = clientContext.Web.Title + " - " + list.Title;
            calendar.Timezone = Timezone.Parse(clientContext.Web.RegionalSettings.TimeZone.Description);
            calendar.Events   = items.Select(i => Event.Parse(i)).ToList <Event>();

            FileContentResult result = File(System.Text.Encoding.Default.GetBytes(calendar.ToString()), "text/calendar", "calendar.ics");

            return(result);
        }
        public async Task <IActionResult> TutorPayrates(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            // get selected unit details
            var unit = await _context.Unit.FindAsync(id);

            // get all classes with an approved tutor
            var classes = await _context.Class.Include(c => c.TutorAllocatedNavigation).Where(Class => Class.UnitId == id && Class.Allocated && Class.Approved).ToListAsync();

            var payrates = await _context.Payrate.ToListAsync();

            // payrates dictionary
            //Dictionary<string, Payrate> payrateValues = new Dictionary<string, Payrate>();

            //foreach (Payrate p in payrates)
            //{
            //    payrateValues.Add(p.Code, p);
            //}

            if (unit == null)
            {
                return(NotFound());
            }

            var model = new UnitTutorsViewModel
            {
                UnitCode = unit.UnitCode,
                Tutors   = new Dictionary <int, TutorPayrateViewModel>()
            };

            foreach (Class c in classes)
            {
                // get calendar. Used to get week # of year
                //https://docs.microsoft.com/en-us/dotnet/api/system.globalization.calendar.getweekofyear?redirectedfrom=MSDN&view=netframework-4.8#System_Globalization_Calendar_GetWeekOfYear_System_DateTime_System_Globalization_CalendarWeekRule_System_DayOfWeek_
                CultureInfo      myCI       = new CultureInfo("en-AU");
                Calendar         myCal      = myCI.Calendar;
                CalendarWeekRule myCWR      = myCI.DateTimeFormat.CalendarWeekRule;
                DayOfWeek        myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;
                int startWeek = myCal.GetWeekOfYear(c.StartDate, myCWR, myFirstDOW);
                int endWeek   = startWeek + 12; // data does not have end week, just assuming 12 weeks of classes + mid semester break

                TutorPayrateViewModel temp = new TutorPayrateViewModel
                {
                    Weeks             = new Dictionary <int, bool>(),
                    ClassStartDate    = c.DateOnlyString,
                    ClassStartTime    = c.StartTimeScheduled,
                    ClassDuration     = c.EndTimeScheduled - c.StartTimeScheduled,
                    ClassType         = c.ClassType,
                    ClassDayOfWeek    = c.DayOfWeek,
                    TutorFullName     = c.TutorAllocatedNavigation.LastName + ", " + c.TutorAllocatedNavigation.FirstName,
                    NewStaff          = false,
                    TutorId           = c.TutorAllocated,
                    TutorFirstName    = c.TutorAllocatedNavigation.FirstName,
                    TutorLastName     = c.TutorAllocatedNavigation.LastName,
                    TutorEmail        = c.TutorAllocatedNavigation.Email,
                    TutorAddress      = c.TutorAllocatedNavigation.Street,
                    TutorSuburb       = c.TutorAllocatedNavigation.City,
                    TutorPostCode     = c.TutorAllocatedNavigation.PostalCode,
                    TutorMobileNumber = c.TutorAllocatedNavigation.PhoneNumber,
                };

                for (int i = startWeek; i <= endWeek; i++)
                {
                    temp.Weeks.Add(i, true); // assume all weeks are teaching weeks for now, allow user to modify with checkboxes
                }
                if (c.TutorAllocatedNavigation.Qualification.ToString() == "PhD")
                {
                    temp.StaffStatus = "Sessional with PhD";
                }
                else
                {
                    temp.StaffStatus = "Sessional without PhD";
                }

                if (c.ClassType.Contains("Lecture"))
                {
                    // not quite sure what requirements are for other lecture payrates, setting to lecturing repeat for now
                    temp.PayrateCode = "LD";
                }
                else if (c.ClassType.Contains("Tutorial") || c.ClassType.Contains("Workshop") || c.ClassType.Contains("Practical") || c.ClassType.Contains("Demonstration") || c.ClassType.Contains("Lab"))
                { // may have missed some class types
                    if (temp.StaffStatus.Equals("Sessional with PhD"))
                    {
                        temp.PayrateCode = "TH";
                    }
                    else
                    {
                        temp.PayrateCode = "TF";
                    }
                }
                model.Tutors.Add(c.Id, temp);
            }
            ViewData["Payrates"] = new SelectList(_context.Payrate, "Code", "Code");
            return(View(model));
        }
Exemple #49
0
        public static Dictionary <string, List <HMEvent> > produceEvents()
        {
            Dictionary <string, List <HMEvent> > dict = new Dictionary <string, List <HMEvent> >();

            // one day
            List <HMEvent> ea  = new List <HMEvent>();
            HMEvent        ea1 = new HMEvent
            {
                name      = "Pay electricty bill",
                location  = "home",
                duraion   = "45m",
                occurence = "Every three month",
                desc      = "This is a notice"
            };
            Calendar cEa1 = Calendar.GetInstance(new Locale("en_AU"));

            // event 1 2018-10-10 9:00:00
            cEa1.Set(field: Calendar.Second, value: 0);
            cEa1.Set(Calendar.Minute, 0);
            cEa1.Set(Calendar.Hour, 9);
            cEa1.Set(Calendar.AmPm, Calendar.Am);
            cEa1.Set(Calendar.Month, Calendar.October);
            cEa1.Set(Calendar.DayOfMonth, 10);
            cEa1.Set(Calendar.Year, 2018);
            ea1.date = cEa1;
            ea.Add(ea1);
            HMEvent ea2 = new HMEvent
            {
                name      = "JD MJ 101 Meeting",
                location  = "Cafe Coffe",
                duraion   = "1h 30m",
                occurence = "Once",
                desc      = "This is a notice"
            };
            Calendar cEa2 = Calendar.GetInstance(new Locale("en_AU"));

            // event 2 2018-10-10 12:30:00
            cEa2.Set(Calendar.Second, 0);
            cEa2.Set(Calendar.Minute, 30);
            cEa2.Set(Calendar.Hour, 12);
            cEa2.Set(Calendar.AmPm, Calendar.Am);
            cEa2.Set(Calendar.Month, Calendar.October);
            cEa2.Set(Calendar.DayOfMonth, 10);
            cEa2.Set(Calendar.Year, 2018);
            ea2.date = cEa2;
            ea.Add(ea2);

            // Another day
            List <HMEvent> eb  = new List <HMEvent>();
            HMEvent        eb1 = new HMEvent
            {
                name      = "Painting company comming",
                location  = "home",
                duraion   = "15m",
                occurence = "Once",
                desc      = "This is a notice"
            };
            Calendar cEb1 = Calendar.GetInstance(new Locale("en_AU"));

            // 2018-10-10 9:00:00
            cEb1.Set(Calendar.Second, 0);
            cEb1.Set(Calendar.Minute, 0);
            cEb1.Set(Calendar.Hour, 9);
            cEb1.Set(Calendar.AmPm, Calendar.Am);
            cEb1.Set(Calendar.Month, Calendar.October);
            cEb1.Set(Calendar.DayOfMonth, 13);
            cEb1.Set(Calendar.Year, 2018);
            eb1.date = cEb1;
            eb.Add(eb1);

            //1
            List <HMEvent> ec  = new List <HMEvent>();
            HMEvent        ec1 = new HMEvent
            {
                name      = "Pay rent",
                location  = "home",
                duraion   = "15m",
                occurence = "Every two weeks",
                desc      = "This is a notice"
            };
            Calendar cEc1 = Calendar.GetInstance(new Locale("en_AU"));

            // 2018-10-28 9:00:00
            cEc1.Set(Calendar.Second, 0);
            cEc1.Set(Calendar.Minute, 0);
            cEc1.Set(Calendar.Hour, 9);
            cEc1.Set(Calendar.AmPm, Calendar.Am);
            cEc1.Set(Calendar.Month, Calendar.October);
            cEc1.Set(Calendar.DayOfMonth, 28);
            cEc1.Set(Calendar.Year, 2018);
            ec1.date = cEc1;
            ec.Add(ec1);


            //2
            List <HMEvent> ed  = new List <HMEvent>();
            HMEvent        ed1 = new HMEvent
            {
                name      = "Pay rent",
                location  = "home",
                duraion   = "15m",
                occurence = "Every two weeks",
                desc      = "This is a notice"
            };
            Calendar cEd1 = Calendar.GetInstance(new Locale("en_AU"));

            // 2018-10-14 9:00:00
            cEd1.Set(Calendar.Second, 0);
            cEd1.Set(Calendar.Minute, 0);
            cEd1.Set(Calendar.Hour, 9);
            cEd1.Set(Calendar.AmPm, Calendar.Am);
            cEd1.Set(Calendar.Month, Calendar.October);
            cEd1.Set(Calendar.DayOfMonth, 14);
            cEd1.Set(Calendar.Year, 2018);
            ed1.date = cEd1;
            ed.Add(ed1);

            //3
            List <HMEvent> ef  = new List <HMEvent>();
            HMEvent        ef1 = new HMEvent
            {
                name      = "Pay rent",
                location  = "home",
                duraion   = "15m",
                occurence = "Every two weeks",
                desc      = "This is a notice"
            };
            Calendar cEf1 = Calendar.GetInstance(new Locale("en_AU"));

            // 2018-11-11 9:00:00
            cEf1.Set(Calendar.Second, 0);
            cEf1.Set(Calendar.Minute, 0);
            cEf1.Set(Calendar.Hour, 9);
            cEf1.Set(Calendar.AmPm, Calendar.Am);
            cEf1.Set(Calendar.Month, Calendar.November);
            cEf1.Set(Calendar.DayOfMonth, 11);
            cEf1.Set(Calendar.Year, 2018);
            ef1.date = cEf1;
            ef.Add(ef1);


            //4
            List <HMEvent> eg  = new List <HMEvent>();
            HMEvent        eg1 = new HMEvent
            {
                name      = "Pay rent",
                location  = "home",
                duraion   = "15m",
                occurence = "Every two weeks",
                desc      = "This is a notice"
            };
            Calendar cEg1 = Calendar.GetInstance(new Locale("en_AU"));

            // 2018-11-25 9:00:00
            cEg1.Set(Calendar.Second, 0);
            cEg1.Set(Calendar.Minute, 0);
            cEg1.Set(Calendar.Hour, 9);
            cEg1.Set(Calendar.AmPm, Calendar.Am);
            cEg1.Set(Calendar.Month, Calendar.November);
            cEg1.Set(Calendar.DayOfMonth, 25);
            cEg1.Set(Calendar.Year, 2018);
            eg1.date = cEg1;
            eg.Add(eg1);

            //5
            List <HMEvent> eh  = new List <HMEvent>();
            HMEvent        eh1 = new HMEvent
            {
                name      = "Pay rent",
                location  = "home",
                duraion   = "15m",
                occurence = "Every two weeks",
                desc      = "This is a notice"
            };
            Calendar cEh1 = Calendar.GetInstance(new Locale("en_AU"));

            // 2018-12-9 9:00:00
            cEh1.Set(Calendar.Second, 0);
            cEh1.Set(Calendar.Minute, 0);
            cEh1.Set(Calendar.Hour, 9);
            cEh1.Set(Calendar.AmPm, Calendar.Am);
            cEh1.Set(Calendar.Month, Calendar.December);
            cEh1.Set(Calendar.DayOfMonth, 9);
            cEh1.Set(Calendar.Year, 2018);
            eh1.date = cEh1;
            eh.Add(eh1);


            //6
            List <HMEvent> ei  = new List <HMEvent>();
            HMEvent        ei1 = new HMEvent
            {
                name      = "Pay rent",
                location  = "home",
                duraion   = "15m",
                occurence = "Every two weeks",
                desc      = "This is a notice"
            };
            Calendar cEi1 = Calendar.GetInstance(new Locale("en_AU"));

            // 2018-12-23 9:00:00
            cEi1.Set(Calendar.Second, 0);
            cEi1.Set(Calendar.Minute, 0);
            cEi1.Set(Calendar.Hour, 9);
            cEi1.Set(Calendar.AmPm, Calendar.Am);
            cEi1.Set(Calendar.Month, Calendar.December);
            cEi1.Set(Calendar.DayOfMonth, 23);
            cEi1.Set(Calendar.Year, 2018);
            ei1.date = cEg1;
            ei.Add(ei1);


            //7
            List <HMEvent> ee  = new List <HMEvent>();
            HMEvent        ee1 = new HMEvent
            {
                name      = "Pay electricty bill",
                location  = "home",
                duraion   = "45m",
                occurence = "Every three month",
                desc      = "This is a notice"
            };
            Calendar cEe1 = Calendar.GetInstance(new Locale("en_AU"));

            // 2018-12-3 9:00:00
            cEe1.Set(Calendar.Second, 0);
            cEe1.Set(Calendar.Minute, 0);
            cEe1.Set(Calendar.Hour, 9);
            cEe1.Set(Calendar.AmPm, Calendar.Am);
            cEe1.Set(Calendar.Month, Calendar.December);
            cEe1.Set(Calendar.DayOfMonth, 1);
            cEe1.Set(Calendar.Year, 2018);
            ee1.date = cEe1;
            ee.Add(ee1);


            String cEa1str = new SimpleDateFormat("MM-dd-yyyy").Format(cEa1.Time);
            String cEb1str = new SimpleDateFormat("MM-dd-yyyy").Format(cEb1.Time);
            String cEc1str = new SimpleDateFormat("MM-dd-yyyy").Format(cEc1.Time);
            String cEd1str = new SimpleDateFormat("MM-dd-yyyy").Format(cEd1.Time);
            String cEe1str = new SimpleDateFormat("MM-dd-yyyy").Format(cEe1.Time);
            String cEf1str = new SimpleDateFormat("MM-dd-yyyy").Format(cEf1.Time);
            String cEg1str = new SimpleDateFormat("MM-dd-yyyy").Format(cEg1.Time);
            String cEh1str = new SimpleDateFormat("MM-dd-yyyy").Format(cEh1.Time);
            String cEi1str = new SimpleDateFormat("MM-dd-yyyy").Format(cEi1.Time);

            dict.Add(cEa1str, ea);
            dict.Add(cEb1str, eb);
            dict.Add(cEc1str, ec);
            dict.Add(cEd1str, ed);
            dict.Add(cEe1str, ee);
            dict.Add(cEf1str, ef);
            dict.Add(cEg1str, eg);
            dict.Add(cEh1str, eh);
            dict.Add(cEi1str, ei);

            return(dict);
        }
Exemple #50
0
 /// <summary>
 /// Construct a new BusinessCalendar based on a localized
 /// culture and non-default calendar.
 /// </summary>
 /// <param name="name">The name of this business calendar.</param>
 /// <param name="culture">The associated <see cref="System.Globalization.CultureInfo"/>.</param>
 /// <param name="calendar">The underlying <see cref="System.Globalization.Calendar"/>.</param>
 protected CalendarBase(String name, CultureInfo culture, Calendar calendar)
 {
     _name    = name;
     Calendar = calendar;
     _culture = culture;
 }
 private static string SerializeToString(Calendar c) => GetNewSerializer().SerializeToString(c);
Exemple #52
0
        public void ShowCalendar()
        {
            popup        = new Window(WindowType.Popup);
            popup.Screen = parent.Screen;

            Frame frame = new Frame();

            frame.Shadow = ShadowType.Out;
            frame.Show();

            popup.Add(frame);

            VBox box = new VBox(false, 0);

            box.Show();
            frame.Add(box);

            cal = new Calendar();
            cal.DisplayOptions = CalendarDisplayOptions.ShowHeading
                                 | CalendarDisplayOptions.ShowDayNames
                                 | CalendarDisplayOptions.ShowWeekNumbers;

            cal.KeyPressEvent      += OnCalendarKeyPressed;
            popup.ButtonPressEvent += OnButtonPressed;

            cal.Show();

            Alignment calAlignment = new Alignment(0.0f, 0.0f, 1.0f, 1.0f);

            calAlignment.Show();
            calAlignment.SetPadding(4, 4, 4, 4);
            calAlignment.Add(cal);

            box.PackStart(calAlignment, false, false, 0);

            //Requisition req = SizeRequest();

            parent.GdkWindow.GetOrigin(out xPos, out yPos);
//			popup.Move(x + Allocation.X, y + Allocation.Y + req.Height + 3);
            popup.Move(xPos, yPos);
            popup.Show();
            popup.GrabFocus();

            Grab.Add(popup);

            Gdk.GrabStatus grabbed = Gdk.Pointer.Grab(popup.GdkWindow, true,
                                                      Gdk.EventMask.ButtonPressMask
                                                      | Gdk.EventMask.ButtonReleaseMask
                                                      | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME);

            if (grabbed == Gdk.GrabStatus.Success)
            {
                grabbed = Gdk.Keyboard.Grab(popup.GdkWindow,
                                            true, CURRENT_TIME);

                if (grabbed != Gdk.GrabStatus.Success)
                {
                    Grab.Remove(popup);
                    popup.Destroy();
                    popup = null;
                }
            }
            else
            {
                Grab.Remove(popup);
                popup.Destroy();
                popup = null;
            }

            cal.DaySelected  += OnCalendarDaySelected;
            cal.MonthChanged += OnCalendarMonthChanged;

            cal.Date = date;
        }
        /// <summary>
        /// Gets the next occurrence of this schedule starting with a base
        /// time and up to an end time limit.
        /// </summary>
        /// <remarks>
        /// This method does not return the value of <paramref name="baseTime"/>
        /// itself if it falls on the schedule. For example, if <paramref name="baseTime" />
        /// is midnight and the schedule was created from the expression <c>* * * * *</c>
        /// (meaning every minute) then the next occurrence of the schedule
        /// will be at one minute past midnight and not midnight itself.
        /// The method returns the <em>next</em> occurrence <em>after</em>
        /// <paramref name="baseTime"/>. Also, <param name="endTime" /> is
        /// exclusive.
        /// </remarks>

        public DateTime GetNextOccurrence(DateTime baseTime, DateTime endTime)
        {
            const int nil = -1;

            var baseYear   = baseTime.Year;
            var baseMonth  = baseTime.Month;
            var baseDay    = baseTime.Day;
            var baseHour   = baseTime.Hour;
            var baseMinute = baseTime.Minute;
            var baseSecond = baseTime.Second;

            var endYear  = endTime.Year;
            var endMonth = endTime.Month;
            var endDay   = endTime.Day;

            var year   = baseYear;
            var month  = baseMonth;
            var day    = baseDay;
            var hour   = baseHour;
            var minute = baseMinute;
            var second = baseSecond + 1;

            //
            // Second
            //

            var seconds = _seconds ?? SecondZero;

            second = seconds.Next(second);

            if (second == nil)
            {
                second = seconds.GetFirst();
                minute++;
            }

            //
            // Minute
            //

            minute = _minutes.Next(minute);

            if (minute == nil)
            {
                minute = _minutes.GetFirst();
                hour++;
            }

            //
            // Hour
            //

            hour = _hours.Next(hour);

            if (hour == nil)
            {
                minute = _minutes.GetFirst();
                hour   = _hours.GetFirst();
                day++;
            }
            else if (hour > baseHour)
            {
                minute = _minutes.GetFirst();
            }

            //
            // Day
            //

            day = _days.Next(day);

RetryDayMonth:

            if (day == nil)
            {
                second = seconds.GetFirst();
                minute = _minutes.GetFirst();
                hour   = _hours.GetFirst();
                day    = _days.GetFirst();
                month++;
            }
            else if (day > baseDay)
            {
                second = seconds.GetFirst();
                minute = _minutes.GetFirst();
                hour   = _hours.GetFirst();
            }

            //
            // Month
            //

            month = _months.Next(month);

            if (month == nil)
            {
                second = seconds.GetFirst();
                minute = _minutes.GetFirst();
                hour   = _hours.GetFirst();
                day    = _days.GetFirst();
                month  = _months.GetFirst();
                year++;
            }
            else if (month > baseMonth)
            {
                second = seconds.GetFirst();
                minute = _minutes.GetFirst();
                hour   = _hours.GetFirst();
                day    = _days.GetFirst();
            }

            //
            // The day field in a cron expression spans the entire range of days
            // in a month, which is from 1 to 31. However, the number of days in
            // a month tend to be variable depending on the month (and the year
            // in case of February). So a check is needed here to see if the
            // date is a border case. If the day happens to be beyond 28
            // (meaning that we're dealing with the suspicious range of 29-31)
            // and the date part has changed then we need to determine whether
            // the day still makes sense for the given year and month. If the
            // day is beyond the last possible value, then the day/month part
            // for the schedule is re-evaluated. So an expression like "0 0
            // 15,31 * *" will yield the following sequence starting on midnight
            // of Jan 1, 2000:
            //
            //  Jan 15, Jan 31, Feb 15, Mar 15, Apr 15, Apr 31, ...
            //

            var dateChanged = day != baseDay || month != baseMonth || year != baseYear;

            if (day > 28 && dateChanged && day > Calendar.GetDaysInMonth(year, month))
            {
                if (year >= endYear && month >= endMonth && day >= endDay)
                {
                    return(endTime);
                }

                day = nil;
                goto RetryDayMonth;
            }

            var nextTime = new DateTime(year, month, day, hour, minute, second, 0, baseTime.Kind);

            if (nextTime >= endTime)
            {
                return(endTime);
            }

            //
            // Day of week
            //

            if (_daysOfWeek.Contains((int)nextTime.DayOfWeek))
            {
                return(nextTime);
            }

            return(GetNextOccurrence(new DateTime(year, month, day, 23, 59, 59, 0, baseTime.Kind), endTime));
        }
 public static DateTime April(this int @this, int year, int hour, int minute, int second, Calendar calendar)
 => new DateTime(year, APRIL, @this, hour, minute, second, calendar);
Exemple #55
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            DateTimeFormatInfo dfi  = DateTimeFormatInfo.CurrentInfo;
            DateTime           date = GlobalVar.GetServerDate;
            Calendar           cal  = dfi.Calendar;
            int mingguKe            = cal.GetWeekOfYear(date, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);

            int bentukPembayaran = 1;

            System.Guid rekeningPembayaranRowID = System.Guid.Empty;

            Database db  = new Database();
            Database dbf = new Database(GlobalVar.DBFinanceOto);

            int counterdb = 0, counterdbf = 0;

            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (ValidateSave())
                {
                }
                else
                {
                    return;
                }

                Guid penerimaanUangRowID;
                Guid pengeluaranUangRowID;
                penerimaanUangRowID  = Guid.NewGuid();
                pengeluaranUangRowID = Guid.NewGuid();

                Exception exDE = new DataException();
                switch (cboBentukPembayaran.SelectedIndex)
                {
                case 0: bentukPembayaran = 1; break;     // kas

                case 1: bentukPembayaran = 2; break;     // bank

                case 2: bentukPembayaran = 5; break;     // potongan pembelian itu nonkasir

                default: throw (exDE); break;
                }

                if (bentukPembayaran == 2)
                {
                    rekeningPembayaranRowID = lookUpRekening1.RekeningRowID;
                }

                penjualanLogInsert(ref db, ref counterdb);
                if (cboTipe.Text == "DP Subsidi" || cboTipe.Text == "Pengurangan DP Subsidi")
                {
                    DPDetailSubsidiInsert(ref db, ref counterdb);
                }
                else
                {
                    lblNoKwitansi.Text = "K" + Numerator.NextNumber("NKJ");

                    penerimaanUMInsert(ref db, ref counterdb, bentukPembayaran, rekeningPembayaranRowID, penerimaanUangRowID, pengeluaranUangRowID);
                    DPDetailSubsidiInsert(ref db, ref counterdb);

                    // masukkin data ke penerimaan Uang
                    // buat no Bukti PenerimaanUang baru
                    String tempBentukPenerimaan = "";
                    switch (cboBentukPembayaran.SelectedIndex + 1)
                    {
                    case 1:     // kalau kas
                        tempBentukPenerimaan = "K";
                        break;

                    case 2:     // kalau transfer
                        tempBentukPenerimaan = "B";
                        break;

                    case 3:     // kalau giro
                        tempBentukPenerimaan = "G";
                        break;

                    case 4:     // kalau titipan
                        tempBentukPenerimaan = "K";
                        break;
                    }
                    Database dbfNumerator = new Database(GlobalVar.DBFinanceOto);

                    if (cboTipe.SelectedIndex == 0 || cboTipe.SelectedIndex == 1) // DP Subsidi / DP Pelanggan
                    {
                        String NoTransPenerimaan = Numerator.GetNomorDokumen(dbfNumerator, "PENERIMAAN_UANG", GlobalVar.PerusahaanID,
                                                                             "/B" + tempBentukPenerimaan.Trim() + "M/" +
                                                                             string.Format("{0:yyMM}", GlobalVar.GetServerDate)
                                                                             , 4, false, true);

                        penerimaanUangInsert(ref dbf, ref counterdbf, rekeningPembayaranRowID, penerimaanUangRowID, NoTransPenerimaan);
                    }
                    else if (cboTipe.SelectedIndex == 2) // Pengembalian DP Pelanggan
                    {
                        String tempBentukPengeluaran = tempBentukPenerimaan;

                        // di bawah ini itu ngebentuk Bukti Uang Keluar untuk komisi!!!
                        String NoTransPengeluaran = Numerator.GetNomorDokumen(dbfNumerator, "PENGAJUAN_PENGELUARAN_UANG", GlobalVar.PerusahaanID, "/B" + tempBentukPengeluaran + "K/" +
                                                                              string.Format("{0:yyMM}", GlobalVar.GetServerDate), 4, false, true); // pake ambil numeratornya finance dan coba pake koding yg punya pengeluaranuang insert???

                        // -- !!!!!!!!!!!!!!!!!!!! tadinya pengeluaranUangRowID itu newGuid !!!, mesti cepet2 dibenerin!!!
                        pengeluaranUangInsert(ref dbf, ref counterdbf, pengeluaranUangRowID, tempBentukPengeluaran, NoTransPengeluaran); // ngga kirim vendor rowid saat komisi
                    }
                }

                updateTambahanUMPelunasan(ref db, ref counterdb);

                db.BeginTransaction();
                dbf.BeginTransaction();
                int looper = 0;
                for (looper = 0; looper < counterdb; looper++)
                {
                    db.Commands[looper].ExecuteNonQuery();
                }
                for (looper = 0; looper < counterdbf; looper++)
                {
                    dbf.Commands[looper].ExecuteNonQuery();
                }
                db.CommitTransaction();
                dbf.CommitTransaction();

                String messageTemp;
                messageTemp = "Data berhasil ditambahkan. \n";

                MessageBox.Show(messageTemp);
                this.Close();
            }
            catch (Exception ex)
            {
                db.RollbackTransaction();
                dbf.RollbackTransaction();
                MessageBox.Show("Data gagal ditambahkan !\n " + ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemple #56
0
 //! fixed reference date, fixed market data
 public ConstantOptionletVolatility(Date referenceDate, Calendar cal, BusinessDayConvention bdc,
                                    double vol, DayCounter dc)
     : base(referenceDate, cal, bdc, dc)
 {
     volatility_ = new Handle <Quote>(new SimpleQuote(vol));
 }
Exemple #57
0
 public PiecewiseFlatForward(int settlementDays, Calendar calendar, RateHelperVector instruments, DayCounter dayCounter, QuoteHandleVector jumps, DateVector jumpDates) : this(NQuantLibcPINVOKE.new_PiecewiseFlatForward__SWIG_7(settlementDays, Calendar.getCPtr(calendar), RateHelperVector.getCPtr(instruments), DayCounter.getCPtr(dayCounter), QuoteHandleVector.getCPtr(jumps), DateVector.getCPtr(jumpDates)), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemple #58
0
 private static string GetCalendarName(Calendar cal)
 {
     return(Regex.Match(cal.ToString(), "\\.(\\w+)Calendar").Groups[1].Value);
 }
Exemple #59
0
            // setup
            public CommonVars()
            {
                backup    = new SavedSettings();
                cleaner   = new IndexHistoryCleaner();
                nominalUK = new RelinkableHandle <YieldTermStructure>();
                cpiUK     = new RelinkableHandle <ZeroInflationTermStructure>();
                hcpi      = new RelinkableHandle <ZeroInflationTermStructure>();
                zciisD    = new List <Date>();
                zciisR    = new List <double>();
                hii       = new RelinkableHandle <ZeroInflationIndex>();

                nominals = new InitializedList <double>(1, 1000000);
                // option variables
                frequency = Frequency.Annual;
                // usual setup
                volatility = 0.01;
                length     = 7;
                calendar   = new UnitedKingdom();
                convention = BusinessDayConvention.ModifiedFollowing;
                Date today = new Date(25, Month.November, 2009);

                evaluationDate = calendar.adjust(today);
                Settings.setEvaluationDate(evaluationDate);
                settlementDays = 0;
                fixingDays     = 0;
                settlement     = calendar.advance(today, settlementDays, TimeUnit.Days);
                startDate      = settlement;
                dcZCIIS        = new ActualActual();
                dcNominal      = new ActualActual();

                // uk rpi index
                //      fixing data
                Date     from        = new Date(20, Month.July, 2007);
                Date     to          = new Date(20, Month.November, 2009);
                Schedule rpiSchedule = new MakeSchedule().from(from).to(to)
                                       .withTenor(new Period(1, TimeUnit.Months))
                                       .withCalendar(new UnitedKingdom())
                                       .withConvention(BusinessDayConvention.ModifiedFollowing).value();

                double[] fixData =
                {
                    206.1,  207.3, 208.0, 208.9, 209.7, 210.9,
                    209.8,  211.4, 212.1, 214.0, 215.1, 216.8,
                    216.5,  217.2, 218.4, 217.7,   216,
                    212.9,  210.1, 211.4, 211.3, 211.5,
                    212.8,  213.4, 213.4, 213.4, 214.4,
                    -999.0, -999.0
                };

                // link from cpi index to cpi TS
                bool interp = false;// this MUST be false because the observation lag is only 2 months

                // for ZCIIS; but not for contract if the contract uses a bigger lag.
                ii = new UKRPI(interp, hcpi);
                for (int i = 0; i < rpiSchedule.Count; i++)
                {
                    ii.addFixing(rpiSchedule[i], fixData[i], true); // force overwrite in case multiple use
                }

                Datum[] nominalData =
                {
                    new Datum(new Date(26, Month.November,  2009),   0.475),
                    new Datum(new Date(2,  Month.December,  2009), 0.47498),
                    new Datum(new Date(29, Month.December,  2009), 0.49988),
                    new Datum(new Date(25, Month.February,  2010), 0.59955),
                    new Datum(new Date(18, Month.March,     2010), 0.65361),
                    new Datum(new Date(25, Month.May,       2010), 0.82830),
                    new Datum(new Date(17, Month.June,      2010),     0.7),
                    new Datum(new Date(16, Month.September, 2010), 0.78960),
                    new Datum(new Date(16, Month.December,  2010), 0.93762),
                    new Datum(new Date(17, Month.March,     2011), 1.12037),
                    new Datum(new Date(22, Month.September, 2011), 1.52011),
                    new Datum(new Date(25, Month.November,  2011), 1.78399),
                    new Datum(new Date(26, Month.November,  2012), 2.41170),
                    new Datum(new Date(25, Month.November,  2013), 2.83935),
                    new Datum(new Date(25, Month.November,  2014), 3.12888),
                    new Datum(new Date(25, Month.November,  2015), 3.34298),
                    new Datum(new Date(25, Month.November,  2016), 3.50632),
                    new Datum(new Date(27, Month.November,  2017), 3.63666),
                    new Datum(new Date(26, Month.November,  2018), 3.74723),
                    new Datum(new Date(25, Month.November,  2019), 3.83988),
                    new Datum(new Date(25, Month.November,  2021), 4.00508),
                    new Datum(new Date(25, Month.November,  2024), 4.16042),
                    new Datum(new Date(26, Month.November,  2029), 4.15577),
                    new Datum(new Date(27, Month.November,  2034), 4.04933),
                    new Datum(new Date(25, Month.November,  2039), 3.95217),
                    new Datum(new Date(25, Month.November,  2049), 3.80932),
                    new Datum(new Date(25, Month.November,  2059), 3.80849),
                    new Datum(new Date(25, Month.November,  2069), 3.72677),
                    new Datum(new Date(27, Month.November,  2079), 3.63082)
                };
                int nominalDataLength = 30 - 1;

                List <Date>   nomD = new List <Date>();
                List <double> nomR = new List <double>();

                for (int i = 0; i < nominalDataLength; i++)
                {
                    nomD.Add(nominalData[i].date);
                    nomR.Add(nominalData[i].rate / 100.0);
                }
                YieldTermStructure nominal = new InterpolatedZeroCurve <Linear>(nomD, nomR, dcNominal);

                nominalUK.linkTo(nominal);

                // now build the zero inflation curve
                observationLag                   = new Period(2, TimeUnit.Months);
                contractObservationLag           = new Period(3, TimeUnit.Months);
                contractObservationInterpolation = InterpolationType.Flat;

                Datum[] zciisData =
                {
                    new Datum(new Date(25, Month.November, 2010),  3.0495),
                    new Datum(new Date(25, Month.November, 2011),    2.93),
                    new Datum(new Date(26, Month.November, 2012),  2.9795),
                    new Datum(new Date(25, Month.November, 2013),   3.029),
                    new Datum(new Date(25, Month.November, 2014),  3.1425),
                    new Datum(new Date(25, Month.November, 2015),   3.211),
                    new Datum(new Date(25, Month.November, 2016),  3.2675),
                    new Datum(new Date(25, Month.November, 2017),  3.3625),
                    new Datum(new Date(25, Month.November, 2018),   3.405),
                    new Datum(new Date(25, Month.November, 2019),    3.48),
                    new Datum(new Date(25, Month.November, 2021),   3.576),
                    new Datum(new Date(25, Month.November, 2024),   3.649),
                    new Datum(new Date(26, Month.November, 2029),   3.751),
                    new Datum(new Date(27, Month.November, 2034), 3.77225),
                    new Datum(new Date(25, Month.November, 2039),    3.77),
                    new Datum(new Date(25, Month.November, 2049),   3.734),
                    new Datum(new Date(25, Month.November, 2059), 3.714)
                };
                zciisDataLength = 17;
                for (int i = 0; i < zciisDataLength; i++)
                {
                    zciisD.Add(zciisData[i].date);
                    zciisR.Add(zciisData[i].rate);
                }

                // now build the helpers ...
                List <BootstrapHelper <ZeroInflationTermStructure> > helpers = makeHelpers(zciisData, zciisDataLength, ii,
                                                                                           observationLag, calendar, convention, dcZCIIS);

                // we can use historical or first ZCIIS for this
                // we know historical is WAY off market-implied, so use market implied flat.
                double baseZeroRate = zciisData[0].rate / 100.0;
                PiecewiseZeroInflationCurve <Linear> pCPIts = new PiecewiseZeroInflationCurve <Linear>(
                    evaluationDate, calendar, dcZCIIS, observationLag, ii.frequency(), ii.interpolated(), baseZeroRate,
                    new Handle <YieldTermStructure>(nominalUK), helpers);

                pCPIts.recalculate();
                cpiUK.linkTo(pCPIts);

                // make sure that the index has the latest zero inflation term structure
                hcpi.linkTo(pCPIts);
            }
        public static List <string[]> getWeekExcelFile()
        {
            //Create COM Objects. Create a COM object for everything that is referenced
            Excel.Application xlApp       = new Excel.Application();
            Excel.Workbook    xlWorkbook  = xlApp.Workbooks.Open(@"C:\Users\michael.gonzalez\source\repos\BirthdayPrg\Book1.xlsx");
            Excel._Worksheet  xlWorksheet = xlWorkbook.Sheets[1];
            Excel.Range       xlRange     = xlWorksheet.UsedRange;

            DateTime date = DateTime.Today; // will give the date for today

            string month = date.Month.ToString();
            string day   = date.Day.ToString();

            CultureInfo myCI  = new CultureInfo("en-US");
            Calendar    myCal = myCI.Calendar;

            CalendarWeekRule myCWR      = myCI.DateTimeFormat.CalendarWeekRule;
            DayOfWeek        myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;

            int weekOfYear = myCal.GetWeekOfYear(DateTime.Now, myCWR, myFirstDOW);

            int rowCount = xlRange.Rows.Count;
            int colCount = xlRange.Columns.Count;

            List <string[]> matches = new List <string[]>();

            //iterate over the rows and columns and print to the console as it appears in the file
            //excel is not zero based!!
            for (int i = 1; i <= rowCount; i++)
            {
                //for (int j = 4; j < colCount; j++)
                //{
                string comparison  = xlRange.Cells[i, 4].Value2.ToString();
                string comparison2 = xlRange.Cells[i, 5].Value2.ToString();
                //new line
                //if (j == 1)
                //Console.Write("\r\n");
                int column = 4;
                if (xlRange.Cells[i, column] != null && xlRange.Cells[i, column].Value2 != null)
                {
                    DateTime dateForWeekCheck = new DateTime(date.Year, Convert.ToInt32(comparison), Convert.ToInt32(comparison2));
                    int      weekForDate      = myCal.GetWeekOfYear(dateForWeekCheck, myCWR, myFirstDOW);
                    if (weekOfYear == weekForDate && column == 4)
                    {
                        string[] strArr = new string[colCount];
                        for (int y = 1; y <= colCount; y++)
                        {
                            strArr[y - 1] = xlRange.Cells[i, y].Value2.ToString();
                        }
                        matches.Add(strArr);
                    }
                }
            }

            //cleanup
            GC.Collect();
            GC.WaitForPendingFinalizers();

            //rule of thumb for releasing com objects:
            //  never use two dots, all COM objects must be referenced and released individually
            //  ex: [somthing].[something].[something] is bad

            //release com objects to fully kill excel process from running in the background
            Marshal.ReleaseComObject(xlRange);
            Marshal.ReleaseComObject(xlWorksheet);

            //close and release
            xlWorkbook.Close();
            Marshal.ReleaseComObject(xlWorkbook);

            //quit and release
            xlApp.Quit();
            Marshal.ReleaseComObject(xlApp);

            return(matches);
        }