Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[iOS] Fixed date formatter issue with different timezone #13634

Merged
merged 1 commit into from
Feb 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Xamarin.Forms.Platform.iOS/Renderers/DatePickerRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@ void UpdateDateFromModel(bool animate)
if (_picker.Date.ToDateTime().Date != Element.Date.Date)
_picker.SetDate(Element.Date.ToNSDate(), animate);

//can't use Element.Format because it won't display the correct format if the region and language are set differently
if (String.IsNullOrWhiteSpace(Element.Format) || Element.Format.Equals("d") || Element.Format.Equals("D"))
// Can't use Element.Format because it won't display the correct format if the region and language are set differently
if (string.IsNullOrWhiteSpace(Element.Format) || Element.Format.Equals("d") || Element.Format.Equals("D"))
{
NSDateFormatter dateFormatter = new NSDateFormatter();
dateFormatter.TimeZone = NSTimeZone.FromGMT(0);

if (Element.Format?.Equals("D") == true)
{
dateFormatter.DateStyle = NSDateFormatterStyle.Long;
Expand Down