public override void SelectionChanged (XuniCalendar sender, CalendarRange selectedDates) { NSDateFormatter dateFormatter = new NSDateFormatter(); dateFormatter.DateFormat = "dd/MM/yyyy"; maskedField.Text = dateFormatter.ToString (sender.NativeSelectedDate); d.IsDropDownOpen = false; }
public static string ToLocalizedTimeString (this DateTime self) { var fmt = new NSDateFormatter () { DateStyle = NSDateFormatterStyle.None, TimeStyle = NSDateFormatterStyle.Short, }; return fmt.ToString (self.ToNSDate ()); }
public UIDateTextField(IntPtr handle) : base(handle) { datePicker = new UIDatePicker(); dateFormatter = new NSDateFormatter(); dateFormatter.DateStyle = NSDateFormatterStyle.Long; // Set up the date picker datePicker.Mode = UIDatePickerMode.Date; datePicker.MinimumDate = DateTime.Today.AddMonths (-2); datePicker.MaximumDate = DateTime.Today; datePicker.ValueChanged += (s, e) => { this.Text = dateFormatter.ToString((s as UIDatePicker).Date); this._currentDate = DateTime.SpecifyKind((s as UIDatePicker).Date, DateTimeKind.Unspecified); }; // Setup the dateToolbar UIToolbar dateToolbar = new UIToolbar(); dateToolbar.BarStyle = UIBarStyle.Black; dateToolbar.Translucent = true; dateToolbar.SizeToFit(); // Create a 'done' button for the dateToolbar UIBarButtonItem dateDoneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => { this.ResignFirstResponder(); }); // Create flexible space UIBarButtonItem dateFlex = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace); // Add button and dateFlexible space to the dateToolbar dateToolbar.SetItems(new UIBarButtonItem[]{dateFlex, dateDoneButton}, true); this.InputView = datePicker; this.InputAccessoryView = dateToolbar; }
async void DatePickerButtonTapped (object sender, EventArgs e) { var modalPicker = new ModalPickerViewController(ModalPickerType.Date, "Select A Date", this) { HeaderBackgroundColor = UIColor.Red, HeaderTextColor = UIColor.White, TransitioningDelegate = new ModalPickerTransitionDelegate(), ModalPresentationStyle = UIModalPresentationStyle.Custom }; modalPicker.DatePicker.Mode = UIDatePickerMode.Date; modalPicker.OnModalPickerDismissed += (s, ea) => { var dateFormatter = new NSDateFormatter() { DateFormat = "MMMM dd, yyyy" }; PickedLabel.Text = dateFormatter.ToString(modalPicker.DatePicker.Date); }; await PresentViewControllerAsync(modalPicker, true); }
protected override string Convert(DateTime value, Type targetType, object parameter, CultureInfo culture) { return(_dateFormatter?.ToString((NSDate)value) ?? value.ToString(CultureInfo.CurrentUICulture)); }
/// <summary> /// Updates the text field values representing different date styles. /// </summary> private void updateDateResult () { NSDate theDate = datePickerControl.DateValue; if (theDate != null) { NSDateFormatter formatter = new NSDateFormatter (); string formattedDateString; /* some examples: formatter.DateStyle = NSDateFormatterStyle.None; // <no date displayed> formatter.DateStyle = NSDateFormatterStyle.Medium; // Jan 24, 1984 formatter.DateStyle = NSDateFormatterStyle.Short; // 1/24/84 formatter.DateStyle = NSDateFormatterStyle.Long; // January 24, 1984 formatter.DateStyle = NSDateFormatterStyle.Full; // Tuesday, January 24, 1984 formatter.TimeStyle = NSDateFormatterStyle.None; // <no time displayed> formatter.TimeStyle = NSDateFormatterStyle.Short; // 2:44 PM formatter.TimeStyle = NSDateFormatterStyle.Medium; // 2:44:55 PM formatter.TimeStyle = NSDateFormatterStyle.Long; // 2:44:55 PM PDT formatter.TimeStyle = NSDateFormatterStyle.Full; // 2:44:55 PM PDT */ formatter.DateStyle = NSDateFormatterStyle.Short; formatter.TimeStyle = NSDateFormatterStyle.None; formattedDateString = formatter.ToString (theDate); dateResult1.StringValue = formattedDateString; formatter.DateStyle = NSDateFormatterStyle.Short; formatter.TimeStyle = NSDateFormatterStyle.Short; formattedDateString = formatter.ToString (theDate); dateResult2.StringValue = formattedDateString; formatter.DateStyle = NSDateFormatterStyle.Medium; formatter.TimeStyle = NSDateFormatterStyle.Short; formattedDateString = formatter.ToString (theDate); dateResult3.StringValue = formattedDateString; formatter.DateStyle = NSDateFormatterStyle.Long; formatter.TimeStyle = NSDateFormatterStyle.Short; formattedDateString = formatter.ToString (theDate); dateResult4.StringValue = formattedDateString; formatter.DateStyle = NSDateFormatterStyle.Full; formatter.TimeStyle = NSDateFormatterStyle.Full; formattedDateString = formatter.ToString (theDate); dateResult5.StringValue = formattedDateString; } }
public CustomizationRangeNavigator() { rangeNavigator = new SFDateTimeRangeNavigator(); lblTitle = new UILabel(); lblTitle.TextAlignment = UITextAlignment.Center; lblTitle.Font = UIFont.FromName("Helvetica", 14f); lblValue = new UILabel(); lblValue.TextAlignment = UITextAlignment.Center; lblValue.Font = UIFont.FromName("Helvetica", 14f); rangeNavigator.ShowTooltip = false; rangeNavigator.Delegate = new CustomizationDelegate(lblTitle, lblValue); DateTime minDate = new DateTime(2015, 1, 1, 0, 0, 0); DateTime maxDate = new DateTime(2015, 12, 1, 0, 0, 0); DateTime startDate = new DateTime(2015, 6, 15, 0, 0, 0); DateTime endDate = new DateTime(2015, 9, 15, 0, 0, 0); rangeNavigator.Minimum = DateTimeToNSDate(minDate); rangeNavigator.Maximum = DateTimeToNSDate(maxDate); rangeNavigator.ViewRangeStart = DateTimeToNSDate(startDate); rangeNavigator.ViewRangeEnd = DateTimeToNSDate(endDate); rangeNavigator.EdgeInsets = new UIEdgeInsets(0, 0, 20, 0); rangeNavigator.Content.Layer.BorderWidth = 1.0f; rangeNavigator.Content.Layer.BorderColor = UIColor.LightGray.CGColor; rangeNavigator.LeftThumbStyle.LineWidth = 3.0f; rangeNavigator.LeftThumbStyle.Width = 28.0f; rangeNavigator.LeftThumbStyle.LineColor = UIColor.FromRGBA(95.0f / 255.0f, 104.0f / 255.0f, 114.0f / 255.0f, 1.0f); rangeNavigator.RightThumbStyle.LineWidth = 3.0f; rangeNavigator.RightThumbStyle.Width = 28.0f; rangeNavigator.RightThumbStyle.LineColor = UIColor.FromRGBA(95.0f / 255.0f, 104.0f / 255.0f, 114.0f / 255.0f, 1.0f); rangeNavigator.MinorScaleStyle.IsVisible = false; rangeNavigator.MinorScaleStyle.ShowGridLines = false; rangeNavigator.MajorScaleStyle.LabelTextColor = UIColor.FromRGBA(95.0f / 255.0f, 104.0f / 255.0f, 114.0f / 255.0f, 1.0f); rangeNavigator.MajorScaleStyle.SelectedLabelTextColor = UIColor.FromRGBA(28.0f / 255.0f, 178.0f / 255.0f, 213.0f / 255.0f, 1.0f); ChartViewModel dataModel = new ChartViewModel(); SFSplineAreaSeries series = new SFSplineAreaSeries(); series.Alpha = 0.6f; series.BorderColor = UIColor.FromRGBA(28.0f / 255.0f, 178.0f / 255.0f, 213.0f / 255.0f, 1.0f); series.Color = UIColor.FromRGBA(124.0f / 255.0f, 230.0f / 255.0f, 199.0f / 255.0f, 1.0f); series.ItemsSource = dataModel.DateTimeRangeData; series.XBindingPath = "XValue"; series.YBindingPath = "YValue"; ((SFChart)rangeNavigator.Content).Series.Add(series); ThumbLayer thumbLayer = new ThumbLayer(); rangeNavigator.ThumbLayer = thumbLayer; this.AddSubview(lblTitle); this.AddSubview(lblValue); this.AddSubview(rangeNavigator); NSDateFormatter resultFormatter = new NSDateFormatter(); resultFormatter.DateFormat = "MMM dd"; lblTitle.Text = string.Format(@"Data usage cycle: {0} - {1}", resultFormatter.ToString(rangeNavigator.ViewRangeStart), resultFormatter.ToString(rangeNavigator.ViewRangeEnd)); lblValue.Text = string.Format(@"Data usage - 101 MB"); //this.control = this; }
void UpdateLabel() { var now = DateTime.Now; timeDisplayLabel.SetText(dateFormatter.ToString((NSDate)now)); }
private void OnModalPickerDismissed (object sender, EventArgs e) { var dateFormatter = new NSDateFormatter() { DateFormat = "dd.MM.yyyy" }; _dateButton.SetTitle(dateFormatter.ToString(_modalPicker.DatePicker.Date), UIControlState.Normal); _modalPicker.OnModalPickerDismissed -= OnModalPickerDismissed; }
private void DatePicker_ValueChanged(object sender,EventArgs e) { NSDateFormatter formatDate = new NSDateFormatter (); formatDate.DateFormat = "YYYY/MM/dd HH:mm:ss"; this.lbl.Text = formatDate.ToString (this.datePicker.Date); }
public virtual string FormatDate(DateTime dt) { return(fmt.ToString(dt) + " " + dt.ToLocalTime().ToShortTimeString()); }
private static string GetShowTimeText(DateTime?time) { return(time.HasValue ? TimeFormatter.ToString(time.Value.ToNSDate()) : null); }
public void addItem() { NSDateFormatter dateFormatter = new NSDateFormatter() /*alloc*/ /*autorelease*/; dateFormatter.TimeStyle = NSDateFormatterStyle.Medium; string now = dateFormatter.ToString(NSDate.Now); items.Add(string.Format("{0}", now)); this.TableView.ReloadData(); this.stopLoading(); }
public virtual string FormatDate(DateTime dt) { return(string.Format("{0} {1}", fmt.ToString(dt), dt.ToLocalTime().ToShortTimeString())); }
private async void GetMyValidBookedReservations() { ShowLoadingView("Loading data..."); _pickups = new List <Dictionary <string, string> > (); try { var lResult = LocationHelper.GetLocationResult(); if (_selectedMarker != null) { _selectedMarker.Map = null; mapView.Clear(); } if (_currentMarkers != null) { foreach (var marker in _currentMarkers) { marker.Map = null; } _currentMarkers.Clear(); mapView.MarkerInfoWindow = null; } NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "MM/dd/yyyy"; NSDate now = NSDate.FromTimeIntervalSinceReferenceDate((DateTime.Now - (new DateTime(2001, 1, 1, 0, 0, 0))).TotalSeconds); var strNow = dateFormat.ToString(now); var customerID = AppSettings.UserID; // please take a look it, Pavel var dic = new Dictionary <String, String> { { Constant.GETREADYFORPICKUPLIST_CUSTOMERID, "553890" }, { Constant.GETREADYFORPICKUPLIST_CURRENTDATE, "2/13/2015" } }; //var dic = new Dictionary<String, String> //{ // {Constant.GETREADYFORPICKUPLIST_CUSTOMERID, customerID}, // {Constant.GETREADYFORPICKUPLIST_CURRENTDATE, strNow} //}; var result = await AppData.ApiCall(Constant.GETREADYFORPICKUPLIST, dic); var tt = (GetReadyForPickupListResponse)AppData.ParseResponse(Constant.GETREADYFORPICKUPLIST, result); var availableReservations = tt.PickupList; for (int i = 0; i < availableReservations.Count; i++) { var reservation = availableReservations[i]; Task runSync = Task.Factory.StartNew(async() => { var pickupData = await GetPickupDataForReservation(reservation); _pickups.Add(pickupData); }).Unwrap(); runSync.Wait(); } var bounds = new CoordinateBounds(); var listReservations = new List <KeyValuePair <object, string> >(); listReservations.Add(new KeyValuePair <object, string>("0", "Ready for all rides")); foreach (Dictionary <String, String> pickup in _pickups) { var marker = new Marker { Position = new CLLocationCoordinate2D(double.Parse(pickup["Latitude"]), double.Parse(pickup["Longitude"])), Map = mapView, Icon = rotateImage(UIImage.FromBundle(getMapVehicleIconByServiceID(pickup["ServiceID"])), float.Parse(pickup["Angle"])), ZIndex = int.Parse(pickup["ResID"]) }; _currentMarkers.Add(marker); bounds = bounds.Including(marker.Position); listReservations.Add(new KeyValuePair <object, string>(pickup["ResID"], pickup["DisplayTxt"])); //string.Format("Shared Van (7 Passengers) \n 3:45 Pick-Up to Los Angeles", pickup["ResID"], pickup["ResType"]))); } if (_pickups.Count > 0) { btnReadyPickup.BackgroundColor = UIColor.Green; btnReadyPickup.SetTitle(string.Format("READY FOR PICKUP ({0})", _pickups.Count.ToString()), UIControlState.Normal); SetupReadyPickup(txtBtnReadyPickup, listReservations, CallForReadyPickup); } else { btnReadyPickup.BackgroundColor = UIColor.Gray; btnReadyPickup.SetTitle("READY FOR PICKUP", UIControlState.Normal); } bounds = bounds.Including(new CLLocationCoordinate2D(lResult.Latitude, lResult.Longitude)); _selectedMarker = new Marker { Position = new CLLocationCoordinate2D(lResult.Latitude, lResult.Longitude), Map = mapView, Icon = UIImage.FromBundle("icon_mylocation.png") }; mapView.SelectedMarker = _selectedMarker; if (_pickups.Count > 0) { mapView.Animate(CameraUpdate.FitBounds(bounds, 100f)); } mapView.TappedMarker = (map, maker) => { mapView.MarkerInfoWindow = new GMSInfoFor(markerInfoWindow); return(false); }; } catch (Exception ex) { CrashReporter.Report(ex); HideLoadingView(); return; } HideLoadingView(); }
// Custom UIPrintPageRenderer's may override this class to draw a custom print page header. // To illustrate that, this class sets the date in the header. public override void DrawHeaderForPage (int index, RectangleF headerRect) { NSDateFormatter dateFormatter = new NSDateFormatter (); dateFormatter.DateFormat = "MMMM d, yyyy 'at' h:mm a"; NSString dateString = new NSString (dateFormatter.ToString (NSDate.Now)); dateFormatter.Dispose (); dateString.DrawString (headerRect, SystemFont, UILineBreakMode.Clip, UITextAlignment.Right); dateString.Dispose (); }
public override void LayoutSubviews() { foreach (var view in this.Subviews) { view.Frame = new CGRect(Frame.X, 0, Frame.Width, Frame.Height); } CreateOptionView(); scheduleEditor.Editor.Frame = new CGRect(0, 0, this.Frame.Size.Width, this.Frame.Size.Height); scheduleEditor.scrollView.Frame = new CGRect(scheduleEditor.Editor.Frame.X + 10, scheduleEditor.Editor.Frame.Y + 10, scheduleEditor.Editor.Frame.Size.Width - 10, scheduleEditor.Editor.Frame.Size.Height); scheduleEditor.EditorFrameUpdate(); UIImageView image1 = new UIImageView(); UIImageView image2 = new UIImageView(); UIImageView image3 = new UIImageView(); moveToDate = new UIButton(); editorView = new UIButton(); monthText = new UILabel(); headerView = new UIView(); headerView.BackgroundColor = UIColor.FromRGB(214, 214, 214); 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); NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "MMMM YYYY"; string monthName = dateFormat.ToString(startDate); monthText.Text = monthName; monthText.TextColor = UIColor.Black; monthText.TextAlignment = UITextAlignment.Left; moveToDate.AddSubview(image2); headerButton.AddSubview(image1); editorView.AddSubview(image3); string[] tableItems = new string[] { "Day", "Week", "WorkWeek", "Month" }; tableView = new UITableView(); tableView.Frame = new CGRect(0, 0, this.Frame.Size.Width / 2, 60.0f * 4); tableView.Hidden = true; tableView.Source = new ScheduleTableSource(tableItems); string deviceType = UIDevice.CurrentDevice.Model; if (deviceType == "iPhone" || deviceType == "iPod touch") { image1.Frame = new CGRect(0, 0, 60, 60); image1.Image = UIImage.FromFile("black-09.png"); image2.Frame = new CGRect(0, 0, 60, 60); image2.Image = UIImage.FromFile("black-11.png"); image3.Frame = new CGRect(0, 0, 60, 60); image3.Image = UIImage.FromFile("black-10.png"); headerView.Frame = new CGRect(0, 0, this.Frame.Size.Width, 50); moveToDate.Frame = new CGRect((this.Frame.Size.Width / 6) + (this.Frame.Size.Width / 2), -10, this.Frame.Size.Width / 8, 50); editorView.Frame = new CGRect((this.Frame.Size.Width / 6) + (this.Frame.Size.Width / 6) + (this.Frame.Size.Width / 2), -10, this.Frame.Size.Width / 8, 50); headerButton.Frame = new CGRect(-10, -10, this.Frame.Size.Width / 8, 50); monthText.Frame = new CGRect(this.Frame.Size.Width / 8, -10, this.Frame.Size.Width / 2, 60); schedule.Frame = new CGRect(0, 50, this.Frame.Size.Width, this.Frame.Size.Height - 50); } else { schedule.DayViewSettings.WorkStartHour = 7; schedule.DayViewSettings.WorkEndHour = 18; schedule.WeekViewSettings.WorkStartHour = 7; schedule.WeekViewSettings.WorkEndHour = 18; schedule.WorkWeekViewSettings.WorkStartHour = 7; schedule.WorkWeekViewSettings.WorkEndHour = 18; image1.Frame = new CGRect(0, 0, 80, 80); image1.Image = UIImage.FromFile("black-09.png"); image2.Frame = new CGRect(0, 0, 80, 80); image2.Image = UIImage.FromFile("black-11.png"); image3.Frame = new CGRect(0, 0, 80, 80); image3.Image = UIImage.FromFile("black-10.png"); headerView.Frame = new CGRect(0, 0, this.Frame.Size.Width, 60); moveToDate.Frame = new CGRect((this.Frame.Size.Width / 5) + (this.Frame.Size.Width / 2) + (this.Frame.Size.Width / 8), -10, this.Frame.Size.Width / 8, 50); editorView.Frame = new CGRect((this.Frame.Size.Width / 5) + (this.Frame.Size.Width / 5) + (this.Frame.Size.Width / 2), -10, this.Frame.Size.Width / 8, 50); headerButton.Frame = new CGRect(0, -10, this.Frame.Size.Width / 8, 50); monthText.Frame = new CGRect(this.Frame.Size.Width / 8, 5, this.Frame.Size.Width / 2, 50); schedule.Frame = new CGRect(0, 60, this.Frame.Size.Width, this.Frame.Size.Height - 60); } moveToDate.TouchUpInside += MoveToDate_TouchUpInside; headerButton.TouchUpInside += HeaderButton_TouchUpInside; editorView.TouchUpInside += EditorView_TouchUpInside; headerView.AddSubview(moveToDate); headerView.AddSubview(editorView); headerView.AddSubview(monthText); headerView.AddSubview(headerButton); this.AddSubview(schedule); this.AddSubview(headerView); this.AddSubview(scheduleEditor.Editor); this.AddSubview(tableView); base.LayoutSubviews(); }
bool OnTextFieldShouldBeginEditing(UITextField textField) { var modalPicker = new ModalPickerViewController(ModalPickerType.Date, "Select A Date", this) { HeaderBackgroundColor = UIColor.Red, HeaderTextColor = UIColor.White, TransitioningDelegate = new ModalPickerTransitionDelegate(), ModalPresentationStyle = UIModalPresentationStyle.Custom }; modalPicker.DatePicker.Mode = UIDatePickerMode.Date; modalPicker.OnModalPickerDismissed += (s, ea) => { var dateFormatter = new NSDateFormatter() { DateFormat = "MMMM dd, yyyy" }; textField.Text = dateFormatter.ToString(modalPicker.DatePicker.Date); }; PresentViewController(modalPicker, true, null); return false; }
void CalendarDidSelectDate(FSCalendar calendar, NSDate date, FSCalendarMonthPosition monthPosition) { System.Diagnostics.Debug.WriteLine($"Did select date: {DateFormatter.ToString(date)}"); ConfigureVisibleCells(); }
private void UpdateDateLabel() { InvokeOnMainThread (() => { var dateFormatter = new NSDateFormatter () { DateFormat = "EEE MMM dd, h:mm aaa" }; DateTime theTime = newDate.starttime; NSDate tempDate = theTime.DateTimeToNSDate (); DateStartBtn.SetTitle(dateFormatter.ToString (tempDate), UIControlState.Normal); }); }
async void DateTimePikerFechafin(object sender, EventArgs e) { var modalPicker = new ModalPickerViewController(ModalPickerType.Date, "Elije Fecha", this) { HeaderBackgroundColor = UIColor.Red, HeaderTextColor = UIColor.White, TransitioningDelegate = new ModalPickerTransitionDelegate(), ModalPresentationStyle = UIModalPresentationStyle.Custom }; modalPicker.DatePicker.Mode = UIDatePickerMode.DateAndTime; modalPicker.OnModalPickerDismissed += (s, ea) => { var dateFormatterFecha = new NSDateFormatter() { DateFormat = "yyyy-MM-dd" }; var dateFormatterHora = new NSDateFormatter() { DateFormat = "HH:mm:ss" }; NSLocale locale = NSLocale.FromLocaleIdentifier("es_MX"); dateFormatterFecha.Locale = locale; dateFormatterHora.Locale = locale; txtFinal.Text = dateFormatterFecha.ToString(modalPicker.DatePicker.Date) + " " + dateFormatterHora.ToString(modalPicker.DatePicker.Date); }; await PresentViewControllerAsync(modalPicker, true); }