Bug 57855 - [UWP] DateTime.MinValue is not allowed for MinimumDate of DatePicker
Summary: [UWP] DateTime.MinValue is not allowed for MinimumDate of DatePicker
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.3.5
Hardware: PC Windows
: Normal critical
Target Milestone: ---
Assignee: Jimmy [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-06-29 08:45 UTC by OBATA Akio
Modified: 2017-11-06 13:34 UTC (History)
5 users (show)

Tags: ac uwp datetime datepicker fr
Is this bug a regression?: ---
Last known good build:


Attachments
repro project (298.15 KB, application/x-zip-compressed)
2017-07-14 20:44 UTC, Jimmy [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description OBATA Akio 2017-06-29 08:45:22 UTC
# Steps to reproduce

Put something followings on the form's xaml:
<DatePicker MinimumDate="{x:Static sys:DateTime.MinValue}" ...

# Expected behavior

The form is appeared and allowed to pick a date since 0001-01-01

# Actual behavior

The form is not appeared and following is throwed

Exception:
{System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.}

Message:
The UTC time represented when the offset is applied must be between year 0 and 10,000.
Parameter name: offset

# Supplemental info (logs, images, videos)

StackTrace:
   at System.DateTimeOffset.ValidateDate(DateTime dateTime, TimeSpan offset)
   at System.DateTimeOffset..ctor(DateTime dateTime)
   at Xamarin.Forms.Platform.UWP.DatePickerRenderer.UpdateMinimumDate()
   at Xamarin.Forms.Platform.UWP.DatePickerRenderer.OnElementChanged(ElementChangedEventArgs`1 e)
   at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
   at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.OnChildAdded(Object sender, ElementEventArgs e)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.Load()
   at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
   at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.OnChildAdded(Object sender, ElementEventArgs e)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.Load()
   at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
   at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.OnChildAdded(Object sender, ElementEventArgs e)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.Load()
   at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
   at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
   at Xamarin.Forms.Platform.UWP.VisualElementExtensions.GetOrCreateRenderer(VisualElement self)
   at Xamarin.Forms.Platform.UWP.Platform.<SetCurrent>d__45.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)
   at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()

# Test environment (full version information)

			  Windows 10 Pro Version 1703 Build 15063.447

			  Microsoft Visual Studio Community 2017 
			  Version 15.2 (26430.14) Release
			  VisualStudio.15.Release/15.2.0+26430.14
			  Microsoft .NET Framework
			  Version 4.7.02046

			  Xamarin   4.5.0.486 (fec6f88)

			  Timezone Japan/Tokyo (GMT+09:00)
Comment 1 Jimmy [MSFT] 2017-06-30 17:56:18 UTC
I was not able to reproduce this crash with a new sample project. I used both XAML and code and the app loaded successfully each time. I tested with Forms 2.3.4.247 and 2.3.5-pre3.

Are you using the latest Forms version? If so, can you attach a project that reproduces the crash so we can investigate? When providing the requested information, please set the report's status back to NEW otherwise we may close this issue after 30 days of no response. Thanks!
Comment 2 OBATA Akio 2017-07-01 07:33:42 UTC
I'm also using Forms 2.3.4.247.

Are you testing with Timezone having positive offset as described in "Test environment"?
I can reproduce the issue with JST (UTC+09:00), but not happend with EST (UTC-05:00).

It is not reproducible for MaximumDate="{x:Static sys:DateTime.MaxValue}" with both timezone.
In Xamarin.Forms/Xamarin.Forms.Platform.WinRT/DatePickerRenderer.cs,
"UpdateMaximunDate" using "maxdate.Date" whereas UpdateMinimumDate is just "mindate", such diff may relate to this issue.
Comment 3 Jimmy [MSFT] 2017-07-14 20:44:45 UTC
Created attachment 23575 [details]
repro project

Thank you for that info! I can confirm that it does crash on UWP when the UTC offset it +1 or higher. This does not appear to happen on iOS or Android. 


### Version Tests
2.3.6.118   BAD
2.3.5-pre6  BAD
2.3.4.247   BAD
Comment 5 Jimmy [MSFT] 2017-07-14 23:25:18 UTC
https://github.com/xamarin/Xamarin.Forms/pull/1056
Comment 6 Rui Marinho 2017-09-12 12:22:24 UTC
Should be fixed on 2.4.1-pre1