public DateChartView () { SFChart chart = new SFChart (); chart.Title.Text = (NSString)"Average Sales Comparison"; SFDateTimeAxis dateTimeAxis = new SFDateTimeAxis (); dateTimeAxis.EdgeLabelsDrawingMode = SFChartAxisEdgeLabelsDrawingMode.Hide; dateTimeAxis.IntervalType = SFChartDateTimeIntervalType.Years; dateTimeAxis.Interval = new NSNumber(1); NSDateFormatter formatter = new NSDateFormatter (); formatter.DateFormat = "MM/yyyy"; dateTimeAxis.LabelStyle.LabelFormatter = formatter; dateTimeAxis.LabelRotationAngle = -60; chart.PrimaryAxis = dateTimeAxis; chart.PrimaryAxis.Title.Text = new NSString ("Sales Across Years"); chart.SecondaryAxis = new SFNumericalAxis (); chart.SecondaryAxis.Minimum = new NSNumber(0); chart.SecondaryAxis.Maximum = new NSNumber(100); chart.SecondaryAxis.Interval = new NSNumber(10); chart.SecondaryAxis.Title.Text = new NSString ("Sales Amount in Millions (USD)"); NSNumberFormatter numberFormatter = new NSNumberFormatter (); numberFormatter.NumberStyle = NSNumberFormatterStyle.Currency; numberFormatter.MinimumFractionDigits = 0; chart.SecondaryAxis.LabelStyle.LabelFormatter = numberFormatter; DateTimeDataSource dataModel = new DateTimeDataSource (); chart.DataSource = dataModel as SFChartDataSource; this.control = chart; }
public static List<StockDataPoint> LoadStockPoints(int maxItems) { List<StockDataPoint> stockPoints = new List<StockDataPoint> (); string filePath = NSBundle.MainBundle.PathForResource ("AppleStockPrices", "json"); NSData json = NSData.FromFile (filePath); NSError error = new NSError (); NSArray data = (NSArray)NSJsonSerialization.Deserialize (json, NSJsonReadingOptions.AllowFragments, out error); NSDateFormatter formatter = new NSDateFormatter (); formatter.DateFormat = "dd-MM-yyyy"; for (int i = 0; i < (int)data.Count; i++) { if (i == maxItems) { break; } NSDictionary jsonPoint = data.GetItem<NSDictionary> ((nuint)i); StockDataPoint dataPoint = new StockDataPoint (); dataPoint.DataXValue = formatter.Parse ((NSString)jsonPoint ["date"]); dataPoint.Open = (NSNumber)jsonPoint ["open"]; dataPoint.Low = (NSNumber)jsonPoint ["low"]; dataPoint.Close = (NSNumber)jsonPoint ["close"]; dataPoint.Volume = (NSNumber)jsonPoint ["volume"]; dataPoint.High = (NSNumber)jsonPoint ["high"]; stockPoints.Add (dataPoint); } return stockPoints; }
public SettingsTableSource(UITableViewController controller, string cellID) { this.cellID = cellID; this.controller = controller; // Set up the NSDateFormatter this.dateFormatter = new NSDateFormatter(); this.dateFormatter.DateStyle = NSDateFormatterStyle.None; this.dateFormatter.TimeStyle = NSDateFormatterStyle.Short; // Set up the UIDatePicker this.timePicker = new UIDatePicker(); timePicker.Mode = UIDatePickerMode.Time; timePicker.Date = NSDate.Now; timePicker.Hidden = true; this.timePickerIsShowing = false; this.dayPickerDay = 1; this.dayPickerUnit = "Days"; // Set up the UIPickerView this.dayPicker = new UIPickerView(); this.dayPicker.DataSource = new DayPickerSource(); this.dayPicker.Delegate = new DayPickerDelegate(this); this.dayPicker.Hidden = true; this.dayPickerIsShowing = false; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////// /// /// Member functions of the class /// //////////////////////////////////////////////////////////////////////////////////////////////////////////// #region Member Functions /// Purpose: Draw the chart of Umsatz // Example: - void GetData() { PersonUmsatzList = _person.GetPersonTimeUmsatz("36", ref Application._user); NSDateFormatter dateFormatter = new NSDateFormatter { DateFormat = "dd-MM-yyyy" }; for (int i = 0; i < PersonUmsatzList.Count; i++) { DateTime date = DateTime.ParseExact(PersonUmsatzList[i].Date, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); if (date.Year == 4028) date = date.AddYears(-2016); if (date.Year > 2015 || date.Year < 2013) Console.WriteLine("*********************** Wrong Year ******************************"); double closePrice = Double.Parse(PersonUmsatzList[i].Umsatz); SChartDataPoint dataPoint = new SChartDataPoint(); dataPoint.XValue = new NSString(""); string dateString = date.Day.ToString() + "-" + date.Month.ToString() + "-" + date.Year.ToString(); // Console.WriteLine(dateString); dataPoint.XValue = dateFormatter.Parse(dateString.ToString()); Console.WriteLine(dataPoint.XValue.ToString()); // dataPoint.XValue =dateFormatter.Parse( date.ToString()); dataPoint.YValue = new NSNumber(closePrice);// new NSString( closePrice.ToString()); dataPoints.Add(dataPoint); } }
public override string ToString() { NSDateFormatter df = new NSDateFormatter(); df.TimeStyle = NSDateFormatterStyle.None; df.DateStyle = NSDateFormatterStyle.Full; return string.Format("NSDate: {0}\nDateTime: {1} = {2} and {3}", df.StringFor(entryDate), EntryDate.ToLocalTime().ToLongDateString(), firstNumber, secondNumber); }
public override void ViewDidLoad() { base.ViewDidLoad (); controller = this.ParentViewController as PetTabController; // Set all the labels with the pet's info this.BreedLabel.Text = "Breed: " + controller.pet.breed; this.ageLabel.Text = "Age: " + (controller.pet.age < 0 ? "" : controller.pet.age.ToString ()); this.weightLabel.Text = "Weight: " + ( controller.pet.weight < 0 ? "" : controller.pet.weight + " kg"); this.weightLabel.Text = "Weight: " + controller.pet.weight + " kg"; NSDateFormatter format = new NSDateFormatter (); format.TimeStyle = NSDateFormatterStyle.None; format.DateStyle = NSDateFormatterStyle.Medium; this.birthdayLabel.Text = "Birthday: " + (controller.pet.birthday == null ? "" : format.StringFor (controller.pet.birthday)); this.colorLabel.Text = "Color: " + controller.pet.bodyColor; this.eyeColorLabel.Text = "Eye Color: " + controller.pet.eyeColor; this.heightLabel.Text = "Height: " + (controller.pet.height < 0 ? "" : controller.pet.height + " cm"); this.lengthLabel.Text = "Length: " + (controller.pet.length < 0 ? "" : controller.pet.length + " cm"); if (controller.pet.identifyingMarks == null) { this.identifyingMarksLabel.Text = "Identifying Marks: None"; } else { string marks = "Identifying Marks: "; for (int i = 0; i < controller.pet.identifyingMarks.Length; i++) { marks += controller.pet.identifyingMarks [i] + (i == controller.pet.identifyingMarks.Length - 1 ? "" : ", "); }// for this.identifyingMarksLabel.Text = marks; }// if-else this.idChipBrandLabel.Text = "ID Chip Brand: " + controller.pet.idBrand; this.idChipNumberLabel.Text = "ID Chip Number: " + controller.pet.idNumber; this.notesTextView.Text = "Notes : " + controller.pet.notes; this.profilePicture.Image = controller.pet.profilePicture; this.profilePicture.ClipsToBounds = true; }
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 override void ViewDidLoad () { base.ViewDidLoad (); TKChart chart = new TKChart (this.View.Bounds); chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.View.AddSubview (chart); var xAxis = new TKChartDateTimeCategoryAxis (); var formatter = new NSDateFormatter (); formatter.DateFormat = "d MMM"; xAxis.LabelFormatter = formatter; xAxis.Style.MajorTickStyle.TicksOffset = -3; xAxis.Style.MajorTickStyle.TicksHidden = false; xAxis.Style.MajorTickStyle.TicksWidth = 1.5f; xAxis.Style.MajorTickStyle.TicksFill = new TKSolidFill (new UIColor (203 / 255.0f, 203 / 255.0f, 203 / 255.0f, 1f)); xAxis.Style.MajorTickStyle.MaxTickClippingMode = TKChartAxisClippingMode.Visible; xAxis.PlotMode = TKChartAxisPlotMode.BetweenTicks; var yAxis = new TKChartNumericAxis (new NSNumber(320), new NSNumber(360)); yAxis.MajorTickInterval = 20; var series = new TKChartCandlestickSeries(StockDataPoint.LoadStockPoints(10).ToArray()); series.GapLength = 0.6f; series.XAxis = xAxis; chart.YAxis = yAxis; chart.AddSeries (series); }
public override void ViewDidLoad() { base.ViewDidLoad (); this.View.BackgroundColor = UIColor.White; this.reservationForm = new ReservationForm (); this.dataSource = new TKDataFormEntityDataSourceHelper (this.reservationForm); this.dataFormDelegate = new CustomizationDataFormDelegate (); NSDateFormatter formatter = new NSDateFormatter (); formatter.DateFormat = "h:mm a"; this.dataSource.PropertyWithName ("Time").Formatter = formatter; this.dataSource["Name"].Image = new UIImage ("guest-name.png"); this.dataSource["Phone"].Image = new UIImage ("phone.png"); this.dataSource["Date"].Image = new UIImage ("calendar.png"); this.dataSource["Time"].Image = new UIImage ("time.png"); this.dataSource["Guests"].Image = new UIImage ("guest-number.png"); this.dataSource["Table"].Image = new UIImage ("table-number.png"); this.dataSource["Name"].HintText = "Name"; this.dataSource["Name"].ErrorMessage = @"Please fill in the guest name"; this.dataSource["Time"].EditorClass = new ObjCRuntime.Class(typeof(TKDataFormTimePickerEditor)); this.dataSource["Phone"].EditorClass = new ObjCRuntime.Class(typeof(CallEditor)); this.dataSource ["Phone"].HintText = "Phone"; this.dataSource["Origin"].EditorClass = new ObjCRuntime.Class(typeof(TKDataFormSegmentedEditor)); this.dataSource["Guests"].ValuesProvider = new TKRange (new NSNumber(1), new NSNumber(10)); this.dataSource["Section"].ValuesProvider = NSArray.FromStrings (new string[] { "Section 1", "Section 2", "Section 3", "Section 4" }); this.dataSource["Table"].ValuesProvider = NSArray.FromStrings(new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }); this.dataSource["Origin"].ValuesProvider = NSArray.FromStrings (new string[] { "phone", "in-person", "online", "other" }); this.dataSource.AddGroup ("RESERVATION DETAILS", new string[] { "Name", "Phone", "Date", "Time", "Guests" }); this.dataSource.AddGroup ("TABLE DETAILS", new string[] { "Section", "Table" }); this.dataSource.AddGroup ("ORIGIN", new string[] { "Origin" }); this.DataForm.BackgroundColor = UIColor.FromPatternImage (new UIImage ("wood-pattern.png")); this.DataForm.Frame = new CGRect (0, 0, this.View.Bounds.Size.Width, this.View.Bounds.Size.Height - 66); this.DataForm.TintColor = new UIColor (0.780f, 0.2f, 0.223f, 1.0f); this.DataForm.Delegate = this.dataFormDelegate; this.DataForm.WeakDataSource = this.dataSource.NativeObject; btn = new UIButton (new CGRect (0, this.DataForm.Frame.Size.Height, this.View.Bounds.Size.Width, 66)); btn.SetTitle ("Cancel Reservation", UIControlState.Normal); btn.SetTitleColor (new UIColor (0.780f, 0.2f, 0.223f, 1.0f), UIControlState.Normal); btn.AddTarget (this, new ObjCRuntime.Selector ("CancelReservation"), UIControlEvent.TouchUpInside); this.View.AddSubview (btn); }
public static string ToLocalizedTimeString (this DateTime self) { var fmt = new NSDateFormatter () { DateStyle = NSDateFormatterStyle.None, TimeStyle = NSDateFormatterStyle.Short, }; return fmt.ToString (self.ToNSDate ()); }
public BNRMapPoint(string title, CLLocationCoordinate2D coord) { _title = title; this.coord = coord; NSDateFormatter dateFormatter = new NSDateFormatter(); dateFormatter.DateStyle = NSDateFormatterStyle.Medium; dateFormatter.TimeStyle = NSDateFormatterStyle.Short; _subtitle = "Created: " + dateFormatter.StringFor(NSDate.Now); }
public APLParseOperation (NSData data, NSPersistentStoreCoordinator persistentStoreCoordinator) { dateFormatter = new NSDateFormatter () { DateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", TimeZone = NSTimeZone.LocalTimeZone, Locale = NSLocale.FromLocaleIdentifier ("en_US_POSIX") }; earthquakeData = data; sharedPSC = persistentStoreCoordinator; }
public AddingAnnotationsDataSource() { NSDateFormatter dateFormatter = new NSDateFormatter { DateFormat = "dd-MM-yyyy" }; JsonValue stocks = JsonObject.Load(new StreamReader("./AppleStockPrices.json")); foreach (JsonValue stock in stocks) { timeSeries.Add (new SChartDataPoint { XValue = dateFormatter.Parse(stock["date"]), YValue = new NSNumber((double)stock["close"]), }); }; }
protected override void Dispose (bool disposing) { base.Dispose (disposing); if (disposing){ fmt.Dispose (); fmt = null; if (datePicker != null){ datePicker.Dispose (); datePicker = null; } } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { if (fmt != null) { fmt.Dispose(); fmt = null; } } }
public override void ViewDidLoad () { base.ViewDidLoad (); dateFormatter = new NSDateFormatter (); calendar = new XuniCalendar(); calendar.HeaderBackgroundColor = UIColor.White; calendar.Hidden = true; calendar.SelectionChanged+=(object sender, SelectionChangedEventArgs e) => { dateFormatter.DateFormat = "M/d/yyyy"; dateLabel.Text = "The date " + dateFormatter.StringFor(e.SelectedDates.StartDate) + " was selected."; calendar.Hidden = true; if (calendar.Hidden == true) { this.View.BackgroundColor = UIColor.White; this.NavigationController.NavigationBar.BarTintColor = UIColor.White; } }; pickBtn = new UIButton(UIButtonType.System); pickBtn.SetTitle("Pick a date", UIControlState.Normal); pickBtn.TouchUpInside+=(object sender, EventArgs e) => { calendar.Hidden = !calendar.Hidden; if (calendar.Hidden == false) { this.View.BackgroundColor = UIColor.Gray; this.NavigationController.NavigationBar.BarTintColor = UIColor.LightGray; } else { this.View.BackgroundColor = UIColor.White; this.NavigationController.NavigationBar.BarTintColor = UIColor.White; } }; dateLabel = new UILabel(); dateLabel.Text = ""; view = new UIView(); view.BackgroundColor = UIColor.White; view.UserInteractionEnabled = true; view.Layer.CornerRadius = 4; this.View.Add(pickBtn); this.View.Add(dateLabel); this.View.Add(view); this.View.Add(calendar); }
public override void ViewDidLoad() { base.ViewDidLoad (); NSDateFormatter dateFormatter = new NSDateFormatter { DateFormat = "dd-MM-yyyy" }; // Create the chart View.BackgroundColor = UIColor.White; nfloat margin = UserInterfaceIdiomIsPhone ? 10 : 50; CGRect frame = new CGRect (margin, margin, View.Bounds.Width - 2 * margin, View.Bounds.Height - 2 * margin); chart = new ShinobiChart (frame) { Title = "Apple Stock Pirce", AutoresizingMask = ~UIViewAutoresizing.None, LicenseKey = "", // TODO: add your trail license key here! // add X & Y axes, with explicit ranges so that the chart is initially rendered 'zoomed in' XAxis = new SChartDateTimeAxis(new SChartDateRange(dateFormatter.Parse("01-01-2010"), dateFormatter.Parse("01-06-2010"))) { Title = "Date", EnableGesturePanning = true, EnableGestureZooming = true }, YAxis = new SChartNumberAxis(new SChartNumberRange(150, 300)) { Title = "Price (USD)", EnableGesturePanning = true, EnableGestureZooming = true }, DataSource = new MultipleAxesDataSource(), Delegate = new MultipleAxesDelegate() }; // Add a secondary y-axis for volume SChartNumberAxis volumeAxis = new SChartNumberAxis { // Render on the right-hand side AxisPosition = SChartAxisPosition.Reverse, Title = "Volume", // Add an upper padding so that the volume chart occupies the bottom hald of the plot area RangePaddingHigh = new NSNumber(100) }; NSNumberFormatter volumeFormatter = (volumeAxis.LabelFormatter.Formatter as NSNumberFormatter); volumeFormatter.MaximumFractionDigits = 0; volumeFormatter.PositiveSuffix = "M"; volumeFormatter.NegativeSuffix = "M"; // Hide gridlines volumeAxis.Style.MajorGridLineStyle.ShowMajorGridLines = false; chart.AddYAxis (volumeAxis); View.AddSubview (chart); }
public void GetDateFormatFromTemplateTest() { var us_locale = new NSLocale("en_US"); var gb_locale = new NSLocale("en_GB"); const string dateComponents = "yMMMMd"; var dateFormat = NSDateFormatter.GetDateFormatFromTemplate(dateComponents, 0, us_locale); Assert.AreEqual("MMMM d, y", dateFormat, "#US"); dateFormat = NSDateFormatter.GetDateFormatFromTemplate(dateComponents, 0, gb_locale); Assert.AreEqual("d MMMM y", dateFormat, "GB"); }
void ShowLastAccessed () { NSObject lastAccessed = NSUserDefaults.StandardUserDefaults["LastAccessed"]; if(lastAccessed != null) { NSDateFormatter df = new NSDateFormatter(); df.DateStyle = NSDateFormatterStyle.Full; var alert = new UIAlertView("Last Accessed", df.StringFor(lastAccessed), null, "OK"); alert.Show (); } }
/// <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; } }
static NSDateFormatter NewDateFormatter(NSDateFormatter current, NSLocale locale) { var dateStyle = current.DateStyle; var timeStyle = current.TimeStyle; var baseline = BaselineFormatter; var merged = new NSDateFormatter(); merged.Locale = locale; merged.DateStyle = baseline.DateStyle = current.DateStyle = dateStyle; merged.TimeStyle = baseline.TimeStyle = current.TimeStyle = NSDateFormatterStyle.None; var mergedDateFormat = merged.DateFormat; var baselineDateFormat = baseline.DateFormat; var currentDateFormat = current.DateFormat; merged.DateStyle = baseline.DateStyle = current.DateStyle = NSDateFormatterStyle.None; merged.TimeStyle = baseline.TimeStyle = current.TimeStyle = timeStyle; var mergedTimeFormat = merged.DateFormat; var baselineTimeFormat = baseline.DateFormat; var currentTimeFormat = current.DateFormat; merged.DateStyle = baseline.DateStyle = current.DateStyle = dateStyle; merged.TimeStyle = baseline.TimeStyle = current.TimeStyle = timeStyle; if (!current.AMSymbol.Equals(baseline.AMSymbol)) { merged.AMSymbol = current.AMSymbol; } if (!current.PMSymbol.Equals(baseline.PMSymbol)) { merged.PMSymbol = current.PMSymbol; } if (!current.DateFormat.Equals(baseline.DateFormat)) { var format = merged.DateFormat; if (baselineDateFormat != currentDateFormat) { format = format.Replace(mergedDateFormat, currentDateFormat); } if (baselineTimeFormat != currentTimeFormat) { format = format.Replace(mergedTimeFormat, currentTimeFormat); } merged.DateFormat = format; } return(merged); }
void loadData(JobCIS jobDetail) { ///string htmlString = "<html><body><p style='font-family:verdana;margin-left:10px;font-size:15px;'>The MonoTouch API supports two styles of event notification: the Objective-C style that uses a delegate class or the C# style using event notifications.\n\nThe C# style allows the user to add or remove event handlers at runtime by assigning to the events of properties of this class. Event handlers can be anyone of a method, an anonymous methods or a lambda expression. Using the C# style events or properties will override any manual settings to the Objective-C Delegate or WeakDelegate settings.\n\nThe Objective-C style requires the user to create a new class derived from UIWebViewDelegate class and assign it to the UIKit.Delegate property. Alternatively, for low-level control, by creating a class derived from NSObject which has every entry point properly decorated with an [Export] attribute. The instance of this object can then be assigned to the UIWebView.WeakDelegate property.</p><p><b>Hey</b> you. My <b>name </b> is <h1> Joe </h1></p> </body></html>"; //string htmlString = "<html><body><p style='font-family:verdana;margin-left:10px;font-size:15px;'>The MonoTouch API supports two styles of event notification: the Objective-C style that uses a delegate class or the C# style using event notifications.\n\nThe C# style allows the user to add or remove event handlers at runtime by assigning to the events of properties of this class. Event handlers can be anyone of a method, an anonymous methods or a lambda expression. Using the C# style events or properties will override any manual settings to the Objective-C Delegate or WeakDelegate settings.\n\nThe Objective-C style requires the user to create a new class derived from UIWebViewDelegate class and assign it to the UIKit.Delegate property. Alternatively, for low-level control, by creating a class derived from NSObject which has every entry point properly decorated with an [Export] attribute. The instance of this object can then be assigned to the UIWebView.WeakDelegate property.</p><p><b>Hey</b> you. My <b>name </b> is <h1> Joe </h1></p> </body></html>"; string endDate = ""; if (!string.IsNullOrEmpty(jobDetail.PostingEndDate)) { string[] tokens = jobDetail.PostingEndDate.Split(new[] { " " }, StringSplitOptions.None); endDate = tokens[0]; } else if (!string.IsNullOrEmpty(jobDetail.PostedDate)) { string[] tokens = jobDetail.PostedDate.Split(new[] { " " }, StringSplitOptions.None); endDate = tokens[0]; } NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "MM/dd/yyyy"; NSDate date = dateFormat.Parse(endDate); DateTime dt = ConvertNsDateToDateTime(date); endDate = calculateJobPostedDate(dt); if (!string.IsNullOrEmpty(endDate) && !(endDate.Equals("NoContent"))) { this.PostedDateLabel.Text = endDate; } else { this.PostedDateLabel.Hidden = true; this.btnPostedDate.Hidden = true; } //var htmlString = String.Format("<html><body><p style='font-family:verdana;margin-left:10px;font-size:13px;ā> {0} </p></body></html>", jobDetail.Description); //= String.Format("<font face='Helvetica' size='2'> {0}", jobDetail.Description); if (!string.IsNullOrEmpty(jobDetail.Description)) { var htmlString = String.Format("<font face='Helvetica' size='2'> {0}", jobDetail.Description); webView.LoadHtmlString(htmlString, null); } else { webView.LoadHtmlString(string.Format("<html><center><font size=+5 color='red'>An error occurred:<br></font></center></html>"), null); } }
async void DatePickerFechaInicio(object sender, EventArgs e) { var modalPicker = new ModalPickerViewController(ModalPickerType.Date, "Elije una Fecha", this) { HeaderBackgroundColor = UIColor.Red, HeaderTextColor = UIColor.White, TransitioningDelegate = new ModalPickerTransitionDelegate(), ModalPresentationStyle = UIModalPresentationStyle.Custom }; if (!swTodoDia.On) { 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; txtInicio.Text = dateFormatterFecha.ToString(modalPicker.DatePicker.Date) + " " + dateFormatterHora.ToString(modalPicker.DatePicker.Date); }; } else { modalPicker.DatePicker.Mode = UIDatePickerMode.Date; modalPicker.OnModalPickerDismissed += (s, ea) => { var dateFormatterFecha = new NSDateFormatter() { DateFormat = "yyyy-MM-dd" }; NSLocale locale = NSLocale.FromLocaleIdentifier("es_MX"); dateFormatterFecha.Locale = locale; txtInicio.Text = dateFormatterFecha.ToString(modalPicker.DatePicker.Date) + " 00:00:00"; txtFinal.Text = dateFormatterFecha.ToString(modalPicker.DatePicker.Date) + " 23:59:59"; }; } await PresentViewControllerAsync(modalPicker, true); }
public override void ViewDidLoad() { base.ViewDidLoad(); dateFormatter = new NSDateFormatter(); calendar = new XuniCalendar(); calendar.HeaderBackgroundColor = UIColor.White; calendar.Hidden = true; calendar.SelectionChanged += (object sender, SelectionChangedEventArgs e) => { dateFormatter.DateFormat = "M/d/yyyy"; dateLabel.Text = "The date " + dateFormatter.StringFor(e.SelectedDates.StartDate) + " was selected."; calendar.Hidden = true; if (calendar.Hidden == true) { this.View.BackgroundColor = UIColor.White; this.NavigationController.NavigationBar.BarTintColor = UIColor.White; } }; pickBtn = new UIButton(UIButtonType.System); pickBtn.SetTitle("Pick a date", UIControlState.Normal); pickBtn.TouchUpInside += (object sender, EventArgs e) => { calendar.Hidden = !calendar.Hidden; if (calendar.Hidden == false) { this.View.BackgroundColor = UIColor.Gray; this.NavigationController.NavigationBar.BarTintColor = UIColor.LightGray; } else { this.View.BackgroundColor = UIColor.White; this.NavigationController.NavigationBar.BarTintColor = UIColor.White; } }; dateLabel = new UILabel(); dateLabel.Text = ""; view = new UIView(); view.BackgroundColor = UIColor.White; view.UserInteractionEnabled = true; view.Layer.CornerRadius = 4; this.View.Add(pickBtn); this.View.Add(dateLabel); this.View.Add(view); this.View.Add(calendar); }
public override id init() { this = base.init(); if (this != null) { _dateFormatter = new NSDateFormatter(); _dateFormatter.dateStyle = NSDateFormatterStyle.NSDateFormatterMediumStyle; _dateFormatter.timeStyle = NSDateFormatterStyle.NSDateFormatterMediumStyle; _decimalFormatter = new NSNumberFormatter(); _decimalFormatter.numberStyle = NSNumberFormatterStyle.NSNumberFormatterDecimalStyle; } return(this); }
public static string GetFormattedDate(NSDate date) { if (date == null) { return(null); } var dateFormatter = new NSDateFormatter { Locale = new NSLocale("en_US_POSIX"), DateFormat = "MM/dd/yy" }; return(dateFormatter.ToString(date)); }
private bool Is12Hours() { var dateFormatter = new NSDateFormatter(); dateFormatter.DateStyle = NSDateFormatterStyle.None; dateFormatter.TimeStyle = NSDateFormatterStyle.Short; var dateString = dateFormatter.ToString(NSDate.Now); var isTwelveHourFormat = dateString.Contains(dateFormatter.AMSymbol) || dateString.Contains(dateFormatter.PMSymbol); return(isTwelveHourFormat); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { fmt.Dispose(); fmt = null; if (DatePicker != null) { DatePicker.Dispose(); DatePicker = null; } } }
public void Picker(UITextField textField) { var datePicker = new UIDatePicker(); datePicker.Mode = UIDatePickerMode.Date; textField.InputView = datePicker; datePicker.ValueChanged += (sender, e) => { NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "MM/dd/yyyy"; textField.Text = dateFormat.ToString(datePicker.Date); ResignFirstResponder(); }; }
public void setCurrentTime() { NSDate now = DateTime.Now; NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.TimeStyle = NSDateFormatterStyle.Medium; lblTime.Text = dateFormat.StringFor(now); // Will spin the time label (lblTime) //SpinTimeLabel(); // Will "bounce" the time label (lblTime) while fading it in and out. BounceTimeLabel(); }
/// <summary> /// Log the file transfer progress. /// </summary> private void LogProgress(WCSessionFileTransfer fileTransfer) { DispatchQueue.MainQueue.DispatchAsync(() => { var dateFormatter = new NSDateFormatter { TimeStyle = NSDateFormatterStyle.Medium }; var timeString = dateFormatter.StringFor(new NSDate()); var fileName = fileTransfer.File.FileUrl.LastPathComponent; var progress = fileTransfer.Progress.LocalizedDescription ?? "No progress"; this.Log($"- {fileName}: {progress} at {timeString}"); }); }
public static NSDictionary <NSString, NSObject> Convert(this TimeTrackerApp.Services.IIdentifiable item) { var dict = new NSMutableDictionary <NSString, NSObject>(); var jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(item); var propertyDict = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, object> >(jsonStr); foreach (var key in propertyDict.Keys) { if (key.Equals("ID")) { continue; } var nsKey = new NSString(key); NSObject nsVal = null; var value = propertyDict[key]; if (value is string str) { nsVal = new NSString(str); } else if (value is double dblVal) { nsVal = new NSNumber(dblVal); } else if (value is bool boolVal) { nsVal = new NSNumber(boolVal); } else if (Int32.TryParse(value.ToString(), out int intVal)) { nsVal = new NSNumber(intVal); } else if (value is DateTime dtVal) { var formatter = new NSDateFormatter(); var dateFormat = "yyyy-MM-ddHH:mm:ss"; formatter.DateFormat = dateFormat; var dtStr = dtVal.ToString(dateFormat); nsVal = formatter.Parse(dtStr); } if (nsVal != null) { dict.Add(nsKey, nsVal); } } return(NSDictionary <NSString, NSObject> .FromObjectsAndKeys(dict.Values, dict.Keys)); }
partial void BtnAddQuest(NSObject sender) { if (TxtQuestName.Text != "" && TxtEXP.Text != "" && TxtvQuestDescription.Text != "") { if (stages.Count > 0) { if (int.TryParse(TxtEXP.Text, out int num)) { quest = new Quest(); NSDateFormatter formatter = new NSDateFormatter(); formatter.DateFormat = "yyyy/MM/dd hh:mm:ss"; var fecha = formatter.ToString(DpExpiringDate.Date); var expiringDate = DateTime.ParseExact(fecha, "yyyy/MM/dd hh:mm:ss", CultureInfo.InvariantCulture); if (expiringDate > DateTime.Now) { quest.Name = TxtQuestName.Text; quest.Description = TxtvQuestDescription.Text; quest.StartDate = DateTime.Now; quest.ExpiringDate = expiringDate; quest.RewardXP = num; quest.isCompleted = false; quest.Status = true; quest.QuestStages = stages; UserPersistanceClass.myUser.ActiveQuests.Add(quest); fb.AddNewQuest(quest, UserPersistanceClass.myUser.ActiveQuests.Count); } else { showMessage("Warning", "You cannot pick a past date.", this); } } else { showMessage("Warning", "Experience is a numerical field, you know.", this); } } else { showMessage("Warning", "Add one stage at least.", this); } } else { showMessage("Warning", "you missed some fields buddy.", this); } //throw new NotImplementedException(); }
public static string nsDateToString (NSDate date, string format) { string strDate = ""; NSLocale gbLocale = NSLocale.FromLocaleIdentifier ("en_GB"); NSDateFormatter dateFormatter = new NSDateFormatter (); dateFormatter.DateFormat = format; dateFormatter.Locale = gbLocale; try { strDate = dateFormatter.StringFor (date).ToUpper (); } catch (Exception ex) { Console.Out.WriteLine (ex.Message); } return strDate; }
partial void DateTimeChanged(UIDatePicker sender) { //Formatting for Date NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "yyyy-MM-dd"; //Formatting for Time NSDateFormatter timeFormat = new NSDateFormatter(); timeFormat.TimeStyle = NSDateFormatterStyle.Short; //Formatting for Date and Time NSDateFormatter dateTimeformat = new NSDateFormatter(); dateTimeformat.DateStyle = NSDateFormatterStyle.Long; dateTimeformat.TimeStyle = NSDateFormatterStyle.Short; // Figuring out when countdown is finished var currentTime = NSDate.Now; var countDownTimerTime = datePickerView.CountDownDuration; var finishCountdown = currentTime.AddSeconds(countDownTimerTime); //Formatting Countdown display NSDateFormatter coundownTimeformat = new NSDateFormatter(); coundownTimeformat.DateStyle = NSDateFormatterStyle.Medium; coundownTimeformat.TimeStyle = NSDateFormatterStyle.Medium; switch (datePickerMode.SelectedSegment) { case 0: // time dateLabel.Text = timeFormat.ToString(datePickerView.Date); break; case 1: // date dateLabel.Text = dateFormat.ToString(datePickerView.Date); break; case 2: // date & time dateLabel.Text = dateTimeformat.ToString(datePickerView.Date); break; case 3: // counter dateLabel.Text = "Alarm set for:" + coundownTimeformat.ToString(finishCountdown); break; } }
public void getPayementID(Boolean subscription) { NSUrl url = new NSUrl(paymentIdUrl); NSMutableUrlRequest request = new NSMutableUrlRequest(url); NSUrlSession session = null; NSUrlSessionConfiguration myConfig = NSUrlSessionConfiguration.DefaultSessionConfiguration; session = NSUrlSession.FromConfiguration(myConfig); var dictionary = new NSDictionary( "Content-Type", "application/json", "Authorization", secretKey ); if (subscription) { var date = NSDate.FromTimeIntervalSinceNow((3 * 12 * 30) * 24 * 3600); NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "yyyy-MM-dd'T'HH:mm:ss"; var dateString = dateFormat.ToString(date); String data = "{\"subscription\":{\"endDate\":\"{dateString}\",\"interval\":0},\"order\":{\"currency\":\"SEK\",\"amount\":1000,\"reference\":\"MiaSDK-iOS\",\"items\":[{\"unit\":\"pcs\",\"name\":\"Lightning Cable\",\"reference\":\"MiaSDK-iOS\",\"quantity\":1,\"netTotalAmount\":800,\"unitPrice\":800,\"taxRate\":0,\"grossTotalAmount\":800,\"taxAmount\":0},{\"unitPrice\":200,\"quantity\":1,\"grossTotalAmount\":200,\"taxAmount\":0,\"taxRate\":0,\"reference\":\"MiaSDK-iOS\",\"name\":\"Shipping Cost\",\"unit\":\"pcs\",\"netTotalAmount\":200}]},\"checkout\":{\"consumerType\":{\"default\":\"B2C\",\"supportedTypes\":[\"B2C\",\"B2B\"]},\"returnURL\":\"https:\\/\\/127.0.0.1\\/redirect.php\",\"cancelURL\":\"https:\\/\\/127.0.0.1\\/cancel.php\",\"integrationType\":\"HostedPaymentPage\",\"shippingCountries\":[{\"countryCode\":\"SWE\"},{\"countryCode\":\"NOR\"},{\"countryCode\":\"DNK\"}],\"termsUrl\":\"http:\\/\\/localhost:8080\\/terms\"}}"; request.Body = data.Replace("{dateString}", dateString); } else { request.Body = "{\"order\":{\"currency\":\"SEK\",\"amount\":1000,\"reference\":\"MiaSDK-iOS\",\"items\":[{\"unit\":\"pcs\",\"name\":\"Lightning Cable\",\"reference\":\"MiaSDK-iOS\",\"quantity\":1,\"netTotalAmount\":800,\"unitPrice\":800,\"taxRate\":0,\"grossTotalAmount\":800,\"taxAmount\":0},{\"unitPrice\":200,\"quantity\":1,\"grossTotalAmount\":200,\"taxAmount\":0,\"taxRate\":0,\"reference\":\"MiaSDK-iOS\",\"name\":\"Shipping Cost\",\"unit\":\"pcs\",\"netTotalAmount\":200}]},\"checkout\":{\"consumerType\":{\"default\":\"B2C\",\"supportedTypes\":[\"B2C\",\"B2B\"]},\"returnURL\":\"https:\\/\\/127.0.0.1\\/redirect.php\",\"cancelURL\":\"https:\\/\\/127.0.0.1\\/cancel.php\",\"integrationType\":\"HostedPaymentPage\",\"shippingCountries\":[{\"countryCode\":\"SWE\"},{\"countryCode\":\"NOR\"},{\"countryCode\":\"DNK\"}],\"termsUrl\":\"http:\\/\\/localhost:8080\\/terms\"}}"; } request.HttpMethod = "POST"; request.Headers = dictionary; NSUrlSessionTask task = session.CreateDataTask(request, (data, response, error) => { var json = NSJsonSerialization.Deserialize(data, NSJsonReadingOptions.FragmentsAllowed, out error); if ((Foundation.NSString)json.ValueForKey((Foundation.NSString) "hostedPaymentPageUrl") != null && (Foundation.NSString)json.ValueForKey((Foundation.NSString) "paymentId") != null) { InvokeOnMainThread(() => { presentMiaSDK((Foundation.NSString)json.ValueForKey((Foundation.NSString) "paymentId"), (Foundation.NSString)json.ValueForKey((Foundation.NSString) "hostedPaymentPageUrl")); }); } }); task.Resume(); }
public CandlestickChartDataSource() { NSDateFormatter dateFormatter = new NSDateFormatter { DateFormat = "dd-MM-yyyy" }; JsonValue stocks = JsonObject.Load(new StreamReader("./AppleStockPrices.json")); foreach (JsonValue stock in stocks) { timeSeries.Add (new SChartMultiYDataPoint { XValue = dateFormatter.Parse(stock["date"]), YValues = new NSMutableDictionary() { { new NSString(SChartCandlestickSeries.KeyOpen), new NSNumber((double)stock["open"]) }, { new NSString(SChartCandlestickSeries.KeyHigh), new NSNumber((double)stock["high"]) }, { new NSString(SChartCandlestickSeries.KeyLow), new NSNumber((double)stock["low"]) }, { new NSString(SChartCandlestickSeries.KeyClose), new NSNumber((double)stock["close"]) }, } }); }; }
public override void ViewDidLoad() { base.ViewDidLoad(); Gregorian = new NSCalendar(NSCalendarType.Gregorian); DateFormatter = new NSDateFormatter() { DateFormat = "yyyy-MM-dd" }; // Uncomment this to perform an 'initial-week-scope' //Calendar.Scope = FSCalendarScope.Week; // For UITest Calendar.AccessibilityIdentifier = "calendar"; }
partial void BtnNSDate_TouchUpInside(Foundation.NSObject sender) { var currentTime = new NSDate(); NSDateFormatter dateFormatter = new NSDateFormatter(); dateFormatter.DateFormat = "dd 'de' MMMM 'de' yyyy"; NSDateFormatter timeFormatter = new NSDateFormatter(); timeFormatter.DateFormat = "h:m:s a"; NSLocale locale = new NSLocale("es_MX"); dateFormatter.Locale = locale; timeFormatter.Locale = locale; LblDate.Text = dateFormatter.ToString(currentTime); LblTime.Text = timeFormatter.ToString(currentTime); }
public MultipleAxesDataSource() : base() { NSDateFormatter dateFormatter = new NSDateFormatter { DateFormat = "dd-MM-yyyy" }; JsonValue stocks = JsonObject.Load(new StreamReader("./AppleStockPrices.json")); foreach (JsonValue stock in stocks) { _timeSeries.Add (new SChartDataPoint { XValue = dateFormatter.Parse(stock["date"]), YValue = new NSNumber((double)stock["close"]), }); _volumeSeries.Add (new SChartDataPoint { XValue = dateFormatter.Parse(stock["date"]), YValue = new NSNumber((double)stock["volume"] / 1000000.0), }); }; }
partial void AddRecord(NSButton sender) { // date NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "yy/MM/dd eee"; dateFormat.ToString(DateForm.DateValue); //Push data Balance newBalance = new Balance(dateFormat.ToString(DateForm.DateValue), DescForm.StringValue, AmountForm.DoubleValue); var conn = new SQLite.SQLiteConnection(DbPath); conn.Insert(newBalance); PopulateTable(); clearAll(); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { if (Formatter != null) { Formatter.Dispose(); Formatter = null; } if (_datePicker != null) { _datePicker.Dispose(); _datePicker = null; } } }
public string DateToString(NSDate date, double value, NChartValueAxis axis) { // Perform date to string conversion. Let's perform it by the following rule: // - if tick interval is more than one day, show localized string "Day Month Year"; // - otherwise show time string "Month.Day.Year Hours:Minutes". NSDateFormatter formatter = new NSDateFormatter(); if (value >= 86400.0) { formatter.DateFormat = "d MMM YYYY"; } else { formatter.DateFormat = "MM.dd.YYYY HH:mm"; } return(formatter.StringFor(date)); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { if (fmt != null) { fmt.Dispose(); fmt = null; } if (datePicker != null) { datePicker.Dispose(); datePicker = null; } } }
private void GenerarEvento() { RequestAccess(EKEntityType.Event, () => { CLLocation location = new CLLocation(); if (SucursalModel.Sucursal_Id == "1") { location = new CLLocation(20.6766, -103.3812); } else { location = new CLLocation(20.6766, -103.3812); } var structuredLocation = new EKStructuredLocation(); structuredLocation.Title = SucursalModel.Sucursal_Domicilio; structuredLocation.GeoLocation = location; NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "E, d MMM yyyy HH:mm"; NSDate newFormatDate = dateFormat.Parse(this.FechaReservacion); EKEvent newEvent = EKEvent.FromStore(AppHelper.Current.EventStore); DateTime myDate = ((DateTime)newFormatDate).ToLocalTime(); var HoraAntesReunion = myDate.AddHours(1 * -1); newEvent.AddAlarm(EKAlarm.FromDate(DateTimeToNSDate(HoraAntesReunion.AddMinutes(30)))); newEvent.AddAlarm(EKAlarm.FromDate(DateTimeToNSDate(HoraAntesReunion.AddMinutes(45)))); if (myDate != null) { newEvent.StartDate = DateTimeToNSDate(myDate); newEvent.EndDate = DateTimeToNSDate(myDate.AddHours(1)); } newEvent.Title = "Visita de invitados en " + SucursalModel.Sucursal_Descripcion; newEvent.Notes = "Invitados: "; foreach (UsuarioModel Invitado in InvitadosCalendar) { newEvent.Notes = newEvent.Notes + Invitado.Usuario_Nombre + " " + Invitado.Usuario_Apellidos + ". "; } newEvent.Notes = newEvent.Notes + " Asunto: " + Asunto; newEvent.Calendar = AppHelper.Current.EventStore.DefaultCalendarForNewEvents; newEvent.Location = SucursalModel.Sucursal_Domicilio; newEvent.StructuredLocation = structuredLocation; NSError e; AppHelper.Current.EventStore.SaveEvent(newEvent, EKSpan.ThisEvent, out e); }); }
public VerticalChart() { chart = new SFChart(); chart.Legend.Visible = true; chart.Legend.ToggleSeriesVisibility = true; SFDateTimeAxis xAxis = new SFDateTimeAxis(); NSDateFormatter formatter = new NSDateFormatter(); formatter.DateFormat = new NSString("mm:ss"); xAxis.LabelStyle.LabelFormatter = formatter; xAxis.Title.Text = new NSString("Time (s)"); xAxis.ShowMajorGridLines = false; chart.PrimaryAxis = xAxis; SFNumericalAxis yAxis = new SFNumericalAxis(); yAxis.Minimum = new NSNumber(-10); yAxis.Maximum = new NSNumber(10); yAxis.Interval = new NSNumber(10); yAxis.Title.Text = new NSString("Velocity(m/s)"); yAxis.ShowMajorGridLines = false; chart.SecondaryAxis = yAxis; chart.Title.Text = new NSString("Seismograph analysis of country"); chart.Title.Font = UIFont.FromName("Helvetica neue", 15); dataModel = new ChartViewModel(); SFFastLineSeries series = new SFFastLineSeries(); series.LegendIcon = SFChartLegendIcon.Circle; chart.Legend.IconWidth = 14; chart.Legend.IconHeight = 14; series.Label = "Indonesia"; series.ItemsSource = dataModel.verticalData; series.XBindingPath = "XValue"; series.YBindingPath = "YValue"; series.IsTransposed = true; series.EnableAnimation = true; chart.ColorModel.Palette = SFChartColorPalette.Natural; chart.Series.Add(series); this.AddSubview(chart); UpdateData(); }
/// <summary> /// ä½ē½®ę å ±ć®ćć°ćéäæ”ćć¾ćć /// </summary> /// <param name="location">CLLocation</param> /// <param name="type">ä½ē½®ę å ±ć®åå¾ēØ®å„</param> /// <param name="isEnter">ä¾µå „ćļ¼</param> private void AddLocationLog(CLLocation location, string type, bool?isEnter = null) { var adapter = new DbAdapter_iOS(); var formatter = new NSDateFormatter(); formatter.DateFormat = "yyyy/MM/dd HH:mm:ss"; formatter.TimeZone = NSTimeZone.SystemTimeZone; var dateString = formatter.StringFor(location.Timestamp); var detailString = $"{dateString},iOS,{location.Coordinate.Latitude},{location.Coordinate.Longitude},{location.VerticalAccuracy}"; if (isEnter.HasValue) { detailString += $",{(isEnter.Value ? "ä¾µå „" : "éåŗ")}"; } adapter.AddDeviceLog($"ä½ē½®ę å ±åå¾ļ¼{dateString},ē²¾åŗ¦ļ¼{location.VerticalAccuracy},ēØ®å„ļ¼{type}", detailString); }
/// <summary> /// Attachs datepicker to textfield /// </summary> /// <param name="field">Current textfield</param> public void AttachPickers(UITextField field) { UIDatePicker picker = new UIDatePicker(); picker.Mode = UIDatePickerMode.Time; picker.Locale = new NSLocale("RUS"); picker.ValueChanged += (sender, e) => { NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "hh:mm"; var text = field; text.Text = dateFormat.ToString(picker.Date); }; field.InputView = picker; picks.Add(picker); }
public static AsTagitem itemWith(string _tag, float _rssi, float _phase, float _frequency) { AsTagitem item = new AsTagitem(); item.tag = _tag; item.rssi = _rssi; item.phase = _phase; item.frequency = _frequency; item.count = 1; NSDate timeDate = NSDate.Now; NSDateFormatter formatter = new NSDateFormatter(); formatter.DateStyle = NSDateFormatterStyle.Medium; formatter.TimeStyle = NSDateFormatterStyle.Short; formatter.DateFormat = "YYYY/MM/dd HH:mm:ss"; item.dateTime = formatter.ToString(timeDate); return(item); }
// --------------------- What if Date or Time Changes ------------------ void DateTimeChanged(UIDatePicker sender) { // Formatting for Date NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "yyyy-MM-dd"; // Formatting for Time NSDateFormatter timeFormat = new NSDateFormatter(); timeFormat.TimeStyle = NSDateFormatterStyle.Short; // Formatting for Date and Time NSDateFormatter dateTimeformat = new NSDateFormatter(); dateTimeformat.DateStyle = NSDateFormatterStyle.Long; dateTimeformat.TimeStyle = NSDateFormatterStyle.Short; }
partial void btnConfirmar_Touch(UIButton sender) { var OperacionTerminada = false; if (InternetConectionHelper.VerificarConexion()) { DateTime myDate = DateTime.ParseExact(Reservacion.Sala_Fecha, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); if (Reservacion.Sala_Hora_Inicio == "24:00") { Reservacion.Sala_Hora_Inicio = "00:00"; } if (Reservacion.Sala_Hora_Fin == "24:00") { Reservacion.Sala_Hora_Fin = "00:00"; } var asignacion = new SalasJuntasController().AsignarSalaJuntas("ALTA", Reservacion.Sala_Id, KeyChainHelper.GetKey("Usuario_Id"), KeyChainHelper.GetKey("Usuario_Tipo"), myDate, Reservacion.Sala_Hora_Inicio, Reservacion.Sala_Hora_Fin, Reservacion.Creditos_Usados.ToString()); if (asignacion != -1) { OperacionTerminada = true; } else { OperacionTerminada = false; } } if (OperacionTerminada) { this.DismissViewController(true, () => { this.GenerarEvento(Reservacion); NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "yyyy-MM-dd"; NSDate newFormatDate = dateFormat.Parse(FechaReservacion); this.EnviarMail(MenuHelper.Usuario, SalaActual, newFormatDate, Reservacion); this.EventosReservacionesDelegate.ReservacionConfirmada(this.Reservacion); }); } }
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); }
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); }); }
public void setCurrentTime() { NSDate now = (NSDate)DateTime.Now; NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.TimeStyle = NSDateFormatterStyle.Medium; lblTime.Text = dateFormat.StringFor(now); //SpinTimeLabel(); BounceTimeLabel(); }
public ModelController () { var formatter = new NSDateFormatter (); pageData = new List<string> (formatter.MonthSymbols); }
// 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 (); }
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; }
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; }
public AAPLDetailViewController (IntPtr handle) : base (handle) { dateFormatter = new NSDateFormatter (); dateFormatter.DateFormat = NSDateFormatter.GetDateFormatFromTemplate ("HH:mm", 0, NSLocale.CurrentLocale); activityDataManager = new ActivityDataManager (); }