private void UpdatMinMaxYears() { if (_picker == null) { return; } var calendar = new NSCalendar(NSCalendarType.Gregorian); var maximumDateComponents = new NSDateComponents { Day = MaxYear.Day, Month = MaxYear.Month, Year = MaxYear.Year }; _picker.MaximumDate = calendar.DateFromComponents(maximumDateComponents); var minimumDateComponents = new NSDateComponents { Day = MinYear.Day, Month = MinYear.Month, Year = MinYear.Year }; _picker.MinimumDate = calendar.DateFromComponents(minimumDateComponents); }
private ObservableCollection <ScheduleAppointment> CreateAppointments() { NSDate today = new NSDate(); NSCalendar calendar = NSCalendar.CurrentCalendar; // Get the year, month, day from the date NSDateComponents components = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second components.Hour = 10; components.Minute = 0; components.Second = 0; NSDate startDate = calendar.DateFromComponents(components); // Get the year, month, day from the date NSDateComponents endDateComponents = calendar.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second endDateComponents.Hour = 12; endDateComponents.Minute = 0; endDateComponents.Second = 0; NSDate endDate = calendar.DateFromComponents(endDateComponents); ScheduleAppointment appointment = new ScheduleAppointment(); appointment.StartTime = startDate; appointment.EndTime = endDate; appointment.Subject = new NSString("Jeni's B'Day Celebration"); appointment.AppointmentBackground = UIColor.FromRGB(0xA2, 0xC1, 0x39); NSDateComponents components1 = calendar.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second components1.Hour = 11; components1.Minute = 0; components1.Second = 0; components1.Day = components1.Day + 1; NSDate startDate1 = calendar.DateFromComponents(components1); // Get the year, month, day from the date NSDateComponents endDateComponents1 = calendar.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second endDateComponents1.Hour = 13; endDateComponents1.Minute = 30; endDateComponents1.Second = 0; endDateComponents1.Day = endDateComponents1.Day + 1; NSDate endDate1 = calendar.DateFromComponents(endDateComponents1); ScheduleAppointment appointment1 = new ScheduleAppointment(); appointment1.StartTime = startDate1; appointment1.EndTime = endDate1; appointment1.Subject = new NSString("Checkup"); appointment1.AppointmentBackground = UIColor.FromRGB(0xD8, 0x00, 0x73); ObservableCollection <ScheduleAppointment> appCollection = new ObservableCollection <ScheduleAppointment>(); appCollection.Add(appointment); appCollection.Add(appointment1); return(appCollection); }
public override void ViewDidLoad() { base.ViewDidLoad(); // >> getting-started-calendar-cs TKCalendar calendarView = new TKCalendar(this.View.Bounds); calendarView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.View.AddSubview(calendarView); // << getting-started-calendar-cs calendarDelegate = new CalendarDelegate(); // >> getting-started-assigndatasource-cs calendarView.DataSource = new CalendarDataSource(this); // << getting-started-assigndatasource-cs // >> getting-started-event-cs events = new List <TKCalendarEvent> (); NSCalendar calendar = new NSCalendar(NSCalendarType.Gregorian); NSDate date = NSDate.Now; Random r = new Random(); for (int i = 0; i < 3; i++) { TKCalendarEvent ev = new TKCalendarEvent(); ev.Title = "Sample event"; NSDateComponents components = calendar.Components(NSCalendarUnit.Day | NSCalendarUnit.Month | NSCalendarUnit.Year, date); components.Day = r.Next() % 20; ev.StartDate = calendar.DateFromComponents(components); ev.EndDate = calendar.DateFromComponents(components); ev.EventColor = UIColor.Red; events.Add(ev); } // << getting-started-event-cs // >> getting-started-minmaxdate-cs calendarView.MinDate = TKCalendar.DateWithYear(2010, 1, 1, calendar); calendarView.MaxDate = TKCalendar.DateWithYear(2016, 12, 31, calendar); // << getting-started-minmaxdate-cs // calendarDelegate.events = this.events; calendarView.Delegate = calendarDelegate; // >> getting-started-navigatetodate-cs NSDateComponents newComponents = new NSDateComponents(); newComponents.Year = 2015; newComponents.Month = 5; newComponents.Day = 1; NSDate newDate = calendarView.Calendar.DateFromComponents(newComponents); // >> navigation-navigate-cs calendarView.NavigateToDate(newDate, true); // << navigation-navigate-cs // << getting-started-navigatetodate-cs calendarView.ReloadData(); }
/// <summary> /// Gets the appointment collection /// </summary> /// <returns>Appointment collection</returns> internal ObservableCollection <Meeting> GetAppointments() { NSDate today = new NSDate(); NSCalendar calendar = NSCalendar.CurrentCalendar; appointmentCollection = new ObservableCollection <Meeting>(); SetEventCollection(); RandomNumbers(); SetFromCollection(); SetToCollection(); SetColorCollection(); for (int i = 0; i < 15; i++) { meeting = new Meeting(); meeting.Color = colorCollection[i]; meeting.EventName = (NSString)eventCollection[i]; meeting.From = fromCollection[i]; // To create all day appointments if (i % 6 == 0 && i != 0) { meeting.IsAllDay = true; } // To create two days span appointment if (i % 5 == 0 && i != 0) { toCollection[i] = fromCollection[i]; var dateComponent = calendar.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day | NSCalendarUnit.Hour | NSCalendarUnit.Minute | NSCalendarUnit.Second, toCollection[i]); dateComponent.Day = dateComponent.Day + 2; toCollection[i] = calendar.DateFromComponents(dateComponent); } // To create 24 hour span appointments if (i % 7 == 0) { toCollection[i] = fromCollection[i]; var dateComponent = calendar.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day | NSCalendarUnit.Hour | NSCalendarUnit.Minute | NSCalendarUnit.Second, toCollection[i]); dateComponent.Hour = dateComponent.Hour + 23; dateComponent.Minute = dateComponent.Minute + 59; toCollection[i] = calendar.DateFromComponents(dateComponent); } // To create minimum height appointments if (eventCollection[i].Contains("alert")) { toCollection[i] = fromCollection[i]; meeting.MinimumHeight = 20; } meeting.To = toCollection[i]; appointmentCollection.Add(meeting); } return(appointmentCollection); }
public override void ViewDidLoad() { base.ViewDidLoad(); TKChart chart = new TKChart(this.View.Bounds); chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.View.AddSubview(chart); NSCalendar calendar = new NSCalendar(NSCalendarType.Gregorian); NSDateComponents dateTimeComponents = new NSDateComponents(); dateTimeComponents.Year = 2013; dateTimeComponents.Day = 1; Random r = new Random(); List <TKChartDataPoint> list = new List <TKChartDataPoint> (); for (int i = 1; i <= 6; i++) { dateTimeComponents.Month = i; list.Add(new TKChartDataPoint(calendar.DateFromComponents(dateTimeComponents), new NSNumber(r.Next() % 100))); } TKChartSplineAreaSeries series = new TKChartSplineAreaSeries(list.ToArray()); series.SelectionMode = TKChartSeriesSelectionMode.Series; dateTimeComponents.Month = 1; NSDate minDate = new NSDate(); NSDate maxDate = new NSDate(); minDate = calendar.DateFromComponents(dateTimeComponents); dateTimeComponents.Month = 6; maxDate = calendar.DateFromComponents(dateTimeComponents); // >> chart-axis-datetime-cs TKChartDateTimeAxis xAxis = new TKChartDateTimeAxis(minDate, maxDate); xAxis.MajorTickIntervalUnit = TKChartDateTimeAxisIntervalUnit.Months; xAxis.MajorTickInterval = 1; // << chart-axis-datetime-cs // >> chart-category-plot-onticks-cs xAxis.PlotMode = TKChartAxisPlotMode.OnTicks; // << chart-category-plot-onticks-cs chart.XAxis = xAxis; chart.AddSeries(series); }
/// <summary> /// create appointments. /// </summary> /// <returns></returns> private IEnumerable <ScheduleAppointment> CreateAppointments() { NSDate today = new NSDate(); SetColors(); SetSubjects(); List <ScheduleAppointment> appCollection = new List <ScheduleAppointment>(); NSCalendar calendar = NSCalendar.CurrentCalendar; // Get the year, month, day from the date NSDateComponents components = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second components.Hour = 10; components.Minute = 0; components.Second = 0; // Get the year, month, day from the date NSDateComponents endDateComponents = calendar.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second endDateComponents.Hour = 12; endDateComponents.Minute = 0; endDateComponents.Second = 0; Random randomNumber = new Random(); for (int i = 0; i < 10; i++) { components.Hour = randomNumber.Next(10, 16); endDateComponents.Hour = components.Hour + randomNumber.Next(1, 1); NSDate startDate = calendar.DateFromComponents(components); NSDate endDate = calendar.DateFromComponents(endDateComponents); ScheduleAppointment appointment = new ScheduleAppointment(); appointment.StartTime = startDate; appointment.EndTime = endDate; components.Day = components.Day + 1; endDateComponents.Day = endDateComponents.Day + 1; appointment.Subject = (NSString)subjectCollection[i]; appointment.AppointmentBackground = colorCollection[i]; if (i == 10 || i == 7) { appointment.IsAllDay = true; } appCollection.Add(appointment); } return(appCollection); }
public static MotionActivityQuery FromDate(NSDate date, int offset) { NSCalendar currentCalendar = NSCalendar.CurrentCalendar; NSDateComponents timeComponents = currentCalendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, date); timeComponents.Hour = 0; timeComponents.Day = timeComponents.Day + offset; NSDate queryStart = currentCalendar.DateFromComponents(timeComponents); timeComponents.Day = timeComponents.Day + 1; NSDate queryEnd = currentCalendar.DateFromComponents(timeComponents); return(new MotionActivityQuery(queryStart, queryEnd, offset == 0)); }
private void EditorView_TouchUpInside(object sender, EventArgs e) { ScheduleEditor.Editor.Hidden = false; Schedule.Hidden = true; HeaderView.Hidden = true; TableView.Hidden = true; NSDate today = new NSDate(); NSCalendar calendar = NSCalendar.CurrentCalendar; // Get the year, month, day from the date NSDateComponents components = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); NSDate startDate = calendar.DateFromComponents(components); ScheduleEditor.LabelSubject.Text = "Subject"; ScheduleEditor.LabelLocation.Text = "Location"; String startDate1 = DateTime.Parse(startDate.ToString()).ToString(); ScheduleEditor.PickerStartDate.SetDate(startDate, true); ScheduleEditor.ButtonStartDate.SetTitle(startDate1, UIControlState.Normal); String endDate = DateTime.Parse(startDate.AddSeconds(3600).ToString()).ToString(); ScheduleEditor.PickerEndDate.SetDate(startDate.AddSeconds(3600), true); ScheduleEditor.ButtonEndDate.SetTitle(endDate, UIControlState.Normal); }
public CalendarBlackoutDates() { //Calendar calendar1 = new SFCalendar(); calendar1.ViewMode = SFCalendarViewMode.SFCalendarViewModeMonth; calendar1.HeaderHeight = 40; this.AddSubview(calendar1); //Setting BlackOutDates NSDate today = new NSDate(); NSCalendar calendar = NSCalendar.CurrentCalendar; // Get the year, month, day from the date NSDateComponents components = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second calendar1.BlackoutDates = new NSMutableArray(); for (int i = 0; i < 5; i++) { NSDate startDate = calendar.DateFromComponents(components); components.Day += 1; calendar1.BlackoutDates.Add(startDate); } appView = new UITableView(); appView.RegisterClassForCellReuse(typeof(UITableViewCell), "Cell"); if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { calendarView.AddSubview(calendar1); this.AddSubview(calendarView); } this.AddSubview(appView); }
private void SetMonthSettings() { monthSettings = new MonthViewSettings(); NSDate today = new NSDate(); NSCalendar calendar = NSCalendar.CurrentCalendar; // Get the year, month, day from the date NSDateComponents components = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second schedule.MonthViewSettings = monthSettings; monthSettings.BlackoutDates = new NSMutableArray(); if (switchBlackOutDates != null && switchBlackOutDates.On) { components.Day -= 3; for (int i = 0; i < 3; i++) { NSDate startDate = calendar.DateFromComponents(components); components.Day += 1; schedule.MonthViewSettings.BlackoutDates.Add(startDate); } } if (switchWeekNumber != null && switchWeekNumber.On) { schedule.MonthViewSettings.ShowWeekNumber = true; } else { schedule.MonthViewSettings.ShowWeekNumber = false; } }
private void EditorView_TouchUpInside(object sender, EventArgs e) { scheduleEditor.Editor.Hidden = false; schedule.Hidden = true; headerView.Hidden = true; tableView.Hidden = true; NSDate today = new NSDate(); NSCalendar calendar = NSCalendar.CurrentCalendar; // Get the year, month, day from the date NSDateComponents components = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); NSDate startDate = calendar.DateFromComponents(components); scheduleEditor.label_subject.Text = "Subject"; scheduleEditor.label_location.Text = "Location"; String _sDate = DateTime.Parse((startDate.ToString())).ToString(); scheduleEditor.picker_startDate.SetDate(startDate, true); scheduleEditor.button_startDate.SetTitle(_sDate, UIControlState.Normal); String _eDate = DateTime.Parse((startDate.AddSeconds(3600).ToString())).ToString(); scheduleEditor.picker_endDate.SetDate(startDate.AddSeconds(3600), true); scheduleEditor.button_endDate.SetTitle(_eDate, UIControlState.Normal); }
public override void ViewDidLoad() { base.ViewDidLoad(); this.CurrentFrame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Size.Width, UIScreen.MainScreen.Bounds.Size.Height); this.AddButton(); //Creating an instance for SfSchedule control SFSchedule schedule = new SFSchedule(); schedule.Frame = new CGRect(0, removeExceptionAppointment.Frame.Bottom, this.CurrentFrame.Size.Width, this.CurrentFrame.Size.Height - removeExceptionAppointment.Frame.Bottom); schedule.ScheduleView = SFScheduleView.SFScheduleViewWeek; NSCalendar calendar = new NSCalendar(NSCalendarType.Gregorian); NSDate today = NSDate.Now; // Get the year, month, day from the date NSDateComponents startDateComponents = calendar.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the year, month, day, hour, minute, second startDateComponents.Year = 2017; startDateComponents.Month = 09; startDateComponents.Day = 03; startDateComponents.Hour = 10; startDateComponents.Minute = 0; startDateComponents.Second = 0; //setting start time for the event NSDate startDate = calendar.DateFromComponents(startDateComponents); //setting end time for the event NSDate endDate = startDate.AddSeconds(2 * 60 * 60); // set moveto date to schedule schedule.MoveToDate(startDate); // Set the exception dates. var exceptionDate1 = startDate; var exceptionDate2 = startDate.AddSeconds(2 * 24 * 60 * 60); exceptionDate3 = startDate.AddSeconds(4 * 24 * 60 * 60); // Add Schedule appointment ScheduleAppointment recurrenceAppointment = new ScheduleAppointment(); recurrenceAppointment.Id = 1; recurrenceAppointment.StartTime = startDate; recurrenceAppointment.EndTime = endDate; recurrenceAppointment.Subject = (NSString)"Occurs Daily"; recurrenceAppointment.AppointmentBackground = UIColor.Blue; recurrenceAppointment.RecurrenceRule = (NSString)"FREQ=DAILY;COUNT=20"; recurrenceAppointment.RecurrenceExceptionDates = new System.Collections.ObjectModel.ObservableCollection <NSDate> { exceptionDate1, exceptionDate2, exceptionDate3 }; scheduleAppointmentCollection.Add(recurrenceAppointment); schedule.ItemsSource = scheduleAppointmentCollection; this.View.AddSubview(schedule); }
private ObservableCollection <ScheduleAppointment> GetChineseAppointments() { NSDate today = new NSDate(); viewModel.SetColors(); viewModel.SetChineseCollectionSubjects(); ObservableCollection <ScheduleAppointment> appCollection = new ObservableCollection <ScheduleAppointment>(); NSCalendar calendar = NSCalendar.CurrentCalendar; // Get the year, month, day from the date NSDateComponents components = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second components.Hour = 10; components.Minute = 0; components.Second = 0; // Get the year, month, day from the date NSDateComponents endDateComponents = calendar.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second endDateComponents.Hour = 12; endDateComponents.Minute = 0; endDateComponents.Second = 0; Random randomNumber = new Random(); for (int i = 0; i < 10; i++) { components.Hour = randomNumber.Next(10, 16); endDateComponents.Hour = components.Hour + randomNumber.Next(1, 3); NSDate startDate = calendar.DateFromComponents(components); NSDate endDate = calendar.DateFromComponents(endDateComponents); ScheduleAppointment appointment = new ScheduleAppointment(); appointment.StartTime = startDate; appointment.EndTime = endDate; components.Day = components.Day + 1; endDateComponents.Day = endDateComponents.Day + 1; appointment.Subject = (NSString)viewModel.ChineseCollection[i]; appointment.AppointmentBackground = viewModel.ColorCollection[i]; appCollection.Add(appointment); } return(appCollection); }
public NSDate DateWithYear(int year, int month, int day) { NSCalendar calendar = new NSCalendar (NSCalendarType.Gregorian); NSDateComponents components = new NSDateComponents (); components.Year = year; components.Month = month; components.Day = day; return calendar.DateFromComponents (components); }
private void PrevMonthBtnClicked(object sender, EventArgs args) { NSCalendar cal = NSCalendar.CurrentCalendar; NSDateComponents comps = cal.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, _calendar.CurrentDate); comps.Month -= 1; _calendar.CurrentDate = cal.DateFromComponents(comps); UpdateMonthTitle(); }
NSMutableArray getEnglishAppointments() { NSDate today = new NSDate(); setColors(); setEnglishCollectionSubjects(); NSMutableArray appCollection = new NSMutableArray(); NSCalendar calendar = NSCalendar.CurrentCalendar; // Get the year, month, day from the date NSDateComponents components = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second components.Hour = 10; components.Minute = 0; components.Second = 0; // Get the year, month, day from the date NSDateComponents endDateComponents = calendar.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second endDateComponents.Hour = 12; endDateComponents.Minute = 0; endDateComponents.Second = 0; Random randomNumber = new Random(); for (int i = 0; i < 10; i++) { components.Hour = randomNumber.Next(10, 16); endDateComponents.Hour = components.Hour + randomNumber.Next(1, 3); NSDate startDate = calendar.DateFromComponents(components); NSDate endDate = calendar.DateFromComponents(endDateComponents); SFAppointment appointment = new SFAppointment(); appointment.StartTime = startDate; appointment.EndTime = endDate; components.Day = components.Day + 1; endDateComponents.Day = endDateComponents.Day + 1; appointment.Subject = (NSString)englishCollection[i]; appointment.AppointmentBackground = colorCollection[i]; appCollection.Add(appointment); } return(appCollection); }
private void UpdateMonthTitle() { NSDateFormatter dateFormatter = new NSDateFormatter(); dateFormatter.DateFormat = "MMMM"; lblCurrentMonth.Text = dateFormatter.ToString(_calendar.CurrentDate); NSCalendar cal = NSCalendar.CurrentCalendar; NSDateComponents comps = cal.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, _calendar.CurrentDate); comps.Month += 1; var nextMonth = cal.DateFromComponents(comps); btnNextMonth.SetTitle(dateFormatter.ToString(nextMonth) + " >", UIControlState.Normal); comps.Month -= 2; var prevMonth = cal.DateFromComponents(comps); btnPrevMonth.SetTitle("< " + dateFormatter.ToString(prevMonth), UIControlState.Normal); }
public NSDate DateWithYear(int year, int month, int day) { NSCalendar calendar = new NSCalendar(NSCalendarType.Gregorian); NSDateComponents components = new NSDateComponents(); components.Year = year; components.Month = month; components.Day = day; return(calendar.DateFromComponents(components)); }
private void UpdateMinMaxYears() { if (_picker == null) { return; } // TODO: support non-gregorian calendars var winCalendar = new Windows.Globalization.Calendar( new string[0], Windows.Globalization.CalendarIdentifiers.Gregorian, Windows.Globalization.ClockIdentifiers.TwentyFourHour); var calendar = new NSCalendar(NSCalendarType.Gregorian); winCalendar.SetDateTime(MaxYear); winCalendar.Month = winCalendar.LastMonthInThisYear; winCalendar.Day = winCalendar.LastDayInThisMonth; var maximumDateComponents = new NSDateComponents { Day = winCalendar.Day, Month = winCalendar.Month, Year = winCalendar.Year }; _picker.MaximumDate = calendar.DateFromComponents(maximumDateComponents); winCalendar.SetDateTime(MinYear); winCalendar.Month = winCalendar.FirstMonthInThisYear; winCalendar.Day = winCalendar.FirstDayInThisMonth; var minimumDateComponents = new NSDateComponents { Day = winCalendar.Day, Month = winCalendar.Month, Year = winCalendar.Year }; _picker.MinimumDate = calendar.DateFromComponents(minimumDateComponents); }
private void Schedule_AppointmentsForDate(object sender, AppointmentsForDateEventArgs e) { NSCalendar calendar = NSCalendar.CurrentCalendar; NSDateComponents components = calendar.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, (NSDate)e.Date); components.Hour = 23; components.Minute = 59; components.Second = 59; NSDate rangeEndDateWithTime = calendar.DateFromComponents(components); NSPredicate predicate = NSPredicate.FromFormat(@"(startTime <= %@) AND (startTime >= %@)", rangeEndDateWithTime, (NSDate)e.Date); }
private void MoveToDate_TouchUpInside(object sender, EventArgs e) { tableView.Hidden = true; NSDate today = new NSDate(); NSCalendar calendar = NSCalendar.CurrentCalendar; // Get the year, month, day from the date NSDateComponents components = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); NSDate startDate = calendar.DateFromComponents(components); schedule.MoveToDate(startDate); }
void AddDataPointsForChart (DateTime XValue, Double YValue) { NSCalendar cal = new NSCalendar (NSCalendarType.Gregorian); NSDateComponents comp = new NSDateComponents (); comp.Day = XValue.Day; comp.Month = XValue.Month; comp.Year = XValue.Year; comp.Hour = XValue.Hour; comp.Minute = XValue.Minute; comp.Second = XValue.Second; DataPoints.Add (new SFChartDataPoint ( cal.DateFromComponents(comp), NSObject.FromObject(YValue))); }
private NSDate GetBreakDate(NSDate visibleDate, int hour, int mins, int secs) { NSCalendar calendar = NSCalendar.CurrentCalendar; NSDate today1 = new NSDate(); NSDateComponents visibleDateCompoents = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, visibleDate); visibleDateCompoents.Hour = hour; visibleDateCompoents.Minute = mins; visibleDateCompoents.Second = secs; return(calendar.DateFromComponents(visibleDateCompoents)); }
private NSDate GetDate(NSDate visibleDate, NSDate startTimeDate) { NSCalendar calendar = NSCalendar.CurrentCalendar; NSDate today1 = new NSDate(); NSDateComponents visibleDateCompoents = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, visibleDate); NSDateComponents startDateCompoents = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day | NSCalendarUnit.Hour | NSCalendarUnit.Minute | NSCalendarUnit.Second, startTimeDate); visibleDateCompoents.Hour = startDateCompoents.Hour; visibleDateCompoents.Minute = startDateCompoents.Minute; visibleDateCompoents.Second = startDateCompoents.Second; return(calendar.DateFromComponents(visibleDateCompoents)); }
public override void ViewDidLoad () { base.ViewDidLoad (); TKChart chart = new TKChart (this.View.Bounds); chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.View.AddSubview (chart); NSCalendar calendar = new NSCalendar (NSCalendarType.Gregorian); NSDateComponents dateTimeComponents = new NSDateComponents (); dateTimeComponents.Year = 2013; dateTimeComponents.Day = 1; Random r = new Random (); List<TKChartDataPoint> list = new List<TKChartDataPoint> (); for (int i = 1; i <= 6; i++) { dateTimeComponents.Month = i; list.Add(new TKChartDataPoint(calendar.DateFromComponents(dateTimeComponents), new NSNumber(r.Next() % 100))); } TKChartSplineAreaSeries series = new TKChartSplineAreaSeries (list.ToArray()); series.SelectionMode = TKChartSeriesSelectionMode.Series; dateTimeComponents.Month = 1; NSDate minDate = new NSDate (); NSDate maxDate = new NSDate (); minDate = calendar.DateFromComponents (dateTimeComponents); dateTimeComponents.Month = 6; maxDate = calendar.DateFromComponents (dateTimeComponents); TKChartDateTimeAxis xAxis = new TKChartDateTimeAxis (minDate, maxDate); xAxis.MajorTickIntervalUnit = TKChartDateTimeAxisIntervalUnit.Months; xAxis.MajorTickInterval = 1; chart.XAxis = xAxis; chart.AddSeries (series); }
public void DateFromComponents() { var cal = new NSCalendar(NSCalendarType.Gregorian); var comps = new NSDateComponents(); comps.Year = 1965; comps.Month = 1; comps.Day = 6; comps.Hour = 14; comps.Minute = 10; comps.Second = 0; comps.TimeZone = new NSTimeZone("Europe/Madrid"); var date = cal.DateFromComponents(comps); Assert.AreEqual(-1135594200d, date.SecondsSinceReferenceDate, "a"); }
private void SetEndTime() { endTimeCollection = new List <NSDate>(); NSCalendar calendar = NSCalendar.CurrentCalendar; NSDate today = new NSDate(); NSDateComponents endDateComponents = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); endDateComponents.Hour = 10; endDateComponents.Minute = 0; endDateComponents.Second = 0; NSDateComponents endDateComponents1 = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); endDateComponents1.Hour = 11; endDateComponents1.Minute = 0; endDateComponents1.Second = 0; NSDateComponents endDateComponents2 = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); endDateComponents2.Hour = 12; endDateComponents2.Minute = 0; endDateComponents2.Second = 0; NSDateComponents endDateComponents3 = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); endDateComponents3.Hour = 14; endDateComponents3.Minute = 0; endDateComponents3.Second = 0; NSDateComponents endDateComponents4 = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); endDateComponents4.Hour = 15; endDateComponents4.Minute = 0; endDateComponents4.Second = 0; NSDateComponents endDateComponents5 = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); endDateComponents5.Hour = 16; endDateComponents5.Minute = 0; endDateComponents5.Second = 0; endTimeCollection.Add(calendar.DateFromComponents(endDateComponents)); endTimeCollection.Add(calendar.DateFromComponents(endDateComponents1)); endTimeCollection.Add(calendar.DateFromComponents(endDateComponents2)); endTimeCollection.Add(calendar.DateFromComponents(endDateComponents3)); endTimeCollection.Add(calendar.DateFromComponents(endDateComponents4)); endTimeCollection.Add(calendar.DateFromComponents(endDateComponents5)); }
public static NSDate ToNSDateUTC(this DateTime date) { NSCalendar calendar = NSCalendar.CurrentCalendar; NSDateComponents comps = new NSDateComponents(); comps.TimeZone = NSTimeZone.FromName(@"UTC"); comps.Day = date.Day; comps.Month = date.Month; comps.Year = date.Year; comps.Hour = date.Hour; comps.Minute = date.Minute; comps.Second = date.Second; var value = calendar.DateFromComponents(comps); return(value); }
private void SetStartTime() { startTimeCollection = new List <NSDate>(); NSCalendar calendar = NSCalendar.CurrentCalendar; NSDate today = new NSDate(); NSDateComponents startDateComponents = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); startDateComponents.Hour = 9; startDateComponents.Minute = 1; startDateComponents.Second = 0; NSDateComponents startDateComponents1 = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); startDateComponents1.Hour = 10; startDateComponents1.Minute = 1; startDateComponents1.Second = 0; NSDateComponents startDateComponents2 = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); startDateComponents2.Hour = 11; startDateComponents2.Minute = 11; startDateComponents2.Second = 0; NSDateComponents startDateComponents3 = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); startDateComponents3.Hour = 13; startDateComponents3.Minute = 1; startDateComponents3.Second = 0; NSDateComponents startDateComponents4 = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); startDateComponents4.Hour = 14; startDateComponents4.Minute = 1; startDateComponents4.Second = 0; NSDateComponents startDateComponents5 = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); startDateComponents5.Hour = 15; startDateComponents5.Minute = 11; startDateComponents5.Second = 0; startTimeCollection.Add(calendar.DateFromComponents(startDateComponents)); startTimeCollection.Add(calendar.DateFromComponents(startDateComponents1)); startTimeCollection.Add(calendar.DateFromComponents(startDateComponents2)); startTimeCollection.Add(calendar.DateFromComponents(startDateComponents3)); startTimeCollection.Add(calendar.DateFromComponents(startDateComponents4)); startTimeCollection.Add(calendar.DateFromComponents(startDateComponents5)); }
partial void OnMinYearChangedPartialNative(DateTimeOffset oldMinYear, DateTimeOffset newMinYear) { if (_picker == null) { return; } var calendar = new NSCalendar(NSCalendarType.Gregorian); var minimumDateComponents = new NSDateComponents { Day = newMinYear.Day, Month = newMinYear.Month, Year = newMinYear.Year }; _picker.MinimumDate = calendar.DateFromComponents(minimumDateComponents); }
public int StepQuery() { var dateComponents = new NSDateComponents(); dateComponents.Day = -1; var cal = new NSCalendar(NSCalendarType.ISO8601); var yesterday = cal.DateFromComponents(dateComponents); var predicate = HKQuery.GetPredicateForSamples(yesterday, new NSDate(), HKQueryOptions.None); var query = new HKSampleQuery(HKObjectType.GetQuantityType(HKQuantityTypeIdentifierKey.StepCount), predicate, 0, null, new HKSampleQueryResultsHandler((retQuery, results, error) => { Console.WriteLine(results.Length); })); _healthStore.ExecuteQuery(query); return(0); }
/// <summary> /// Sets the start time collection for custom appointments /// </summary> private void SetFromCollection() { fromCollection = new List<NSDate>(); int count = 0; for (int i = -10; i < 10; i++) { var today = new NSDate(); NSCalendar calendar = NSCalendar.CurrentCalendar; NSDateComponents components = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day | NSCalendarUnit.Hour | NSCalendarUnit.Minute | NSCalendarUnit.Second, today); components.Day = components.Day + i; components.Hour = randomNumbers[count]; components.Minute = 0; components.Second = 0; var from = calendar.DateFromComponents(components); fromCollection.Add(from); count++; } }
void TurnOnNotifications() { // create notification for every day at specified time var notification = new UILocalNotification (); notification.RepeatInterval = NSCalendarUnit.Day; //set time var time = new NSDateComponents (); time.Hour = (nint)slider.Value; time.Minute = 00; time.Second = 0; //choose calendar var calendar = new NSCalendar (NSCalendarType.Gregorian); //create fire date var date = calendar.DateFromComponents (time); // set the fire date (the date time in which it will fire) notification.FireDate = date; notification.TimeZone = NSTimeZone.DefaultTimeZone; // configure the alert stuff notification.AlertTitle = "The APOD is ready!"; // notification.AlertAction = "Open the app"; notification.AlertBody = "Open the app and check it out!"; notification.UserInfo = NSDictionary.FromObjectAndKey (new NSString ("UserInfo for notification"), new NSString ("Notification")); // modify the badge - has no effect on the Watch notification.ApplicationIconBadgeNumber = 1; // set the sound to be the default sound notification.SoundName = UILocalNotification.DefaultSoundName; // schedule it UIApplication.SharedApplication.ScheduleLocalNotification (notification); }