Skip to content

Commit

Permalink
DatePicker will treat default(DateTime) as null
Browse files Browse the repository at this point in the history
  • Loading branch information
enchev committed Aug 18, 2023
1 parent 8032fde commit 519d8fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Radzen.Blazor/RadzenDatePicker.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public object Value
}
else
{
if (value is DateTime dateTime)
if (value is DateTime dateTime && dateTime != default(DateTime))
{
DateTimeValue = DateTime.SpecifyKind(dateTime, Kind);
}
Expand Down Expand Up @@ -444,7 +444,7 @@ public bool HasValue
{
get
{
return DateTimeValue.HasValue;
return DateTimeValue.HasValue && DateTimeValue != default(DateTime);
}
}

Expand All @@ -456,7 +456,7 @@ public string FormattedValue
{
get
{
return string.Format(Culture, "{0:" + DateFormat + "}", Value);
return HasValue ? string.Format(Culture, "{0:" + DateFormat + "}", Value) : "";
}
}

Expand Down
2 changes: 1 addition & 1 deletion RadzenBlazorDemos/Pages/DatePickerBindValue.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
</div>

@code {
DateTime? value = DateTime.Now;
DateTime value;
}

0 comments on commit 519d8fc

Please sign in to comment.