I have the following code
in an Windows Store Application using C#
:
birthDateTimePicker.Date = DateTime.Now;
if (birthDateTimePicker.Date == DateTime.MinValue)
{
no_date_lable.Visibility = Visibility.Collapsed;
birthDateTimePicker.Visibility = Visibility.Collapsed;
}
Note : this line birthDateTimePicker.Date = DateTime.Now;
is for example really user will selected or it will come from server.
But i get an exception in this line :
if (dt_born_dt == DateTime.MinValue)
What is the reason for the exception thrown :
The UTC time represented when the offset is applied must be between year 0 and 10,000.
Really i tested this in three computers and i got error in one of them!!!
I changed the time zone of my system to (UTC-08:00
) Pacific Time (US & Canada) and didn't get this exception at all and codes worked correctly!
My question is really why this exception occurred in the system that its time zone was (UTC+03:30
) Tehran!
Sorry for my poor english