iOS DateTime issue with Xamarin.Forms 4.2 and Prism?

stesvisstesvis USMember ✭✭✭

Apparently if you update Xamarin Forms to the latest version, make a bindable DateTime property with Prism, and try to add time to it, it does not work anymore.

I have this Prism property MyDate:

private DateTime? _myDate;
public DateTime? MyDate
{
    get { return _myDate; }
    set { SetProperty(ref _myDate, value); }
}

Then I have a calendar where I bind the SelectedDate to MyDate:
<syncfusion:SfCalendar x:Name="calendar" SelectedDate="{Binding MyDate, Mode=TwoWay}" />

Then I have a button that is supposed to take the selected date, and add the current time, and print it using a label:
<Label Text="{Binding MyDateFormatted}"></Label>

private string _myDateFormatted;
public string MyDateFormatted
{
    get { return _myDateFormatted; }
    set { SetProperty(ref _myDateFormatted, value); }
}

// ...

private DelegateCommand _formatCommand;
public DelegateCommand FormatCommand =>
    _formatCommand ?? (_formatCommand = new DelegateCommand(ExecuteFormatCommand));

private void ExecuteFormatCommand()
{
    try
    {
        MyDate = MyDate.Value.Date.Add(DateTime.Now.TimeOfDay);
        MyDateFormatted = $"{MyDate.Value.ToLongDateString()} @ {MyDate.Value.ToShortTimeString()}";
    }
    catch (Exception)
    {
            // handle
    }
}

In android everything works. In iOS it does not add the current time to MyDate and it always shows 12am.

  • If instead of a Prism property I use a regular property such as public DateTime? MyDate { get; set; } it works in iOS too.
  • If instead of a calendar I set MyDate manually on page load, such as MyDate = DateTime.Today.Date and keep the Prism property, it works too.

I don't understand the problem. Is it a Prism property issue? A xamarin forms issue? A calendar issue?
Here's the repo to reproduce it in iOS.
https://github.com/stesvis/DateTimeTest

What does @BrianLagunas think? Could it be due to Prism and some incompatibility with the latest Xamarin Forms?
Thanks everybody

Answers

  • BrianLagunasBrianLagunas USInsider ✭✭✭✭

    Just so you know, there is no such thing as a "Prism property". I would actually lean towards an issue with the Syncfusion controls. Often when someone has an issue binding with a syncfusion control, it has always been the sycnfusion control.

  • stesvisstesvis USMember ✭✭✭

    @BrianLagunas said:
    Just so you know, there is no such thing as a "Prism property". I would actually lean towards an issue with the Syncfusion controls. Often when someone has an issue binding with a syncfusion control, it has always been the sycnfusion control.

    I tend to agree....!

  • Nijamudeen_MohamedNijamudeen_Mohamed INMember ✭✭

    @stesvis We have validated the reported bug from our end. As the calendar specifically deals with date components, we have reset the time to 12 AM internally. Now, we have decided not to touch the time components and logged it as bug and fix will be included in our October 22nd, 2019 weekly NuGet. You can track the status of this report through the below feedback link.

    https://www.syncfusion.com/feedback/9529/ios-avoid-formatting-selected-dates-time-value-to-1200am

    The provided feedback link is private, you need to login to view this feedback.

    Note: I work for Syncfusion

Sign In or Register to comment.