Skip to content

Commit

Permalink
Refactor for iOS DateTimeKind.Unspecified Conversion #5
Browse files Browse the repository at this point in the history
  • Loading branch information
dimonovdd authored Aug 20, 2021
2 parents f928e6a + 7cb43c0 commit 1977d62
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions DateTimePopups/DateTimePopups.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<Title>Xamarin.DateTimePopups</Title>
<Description>Little library of popups for picking dates and times</Description>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<AssemblyVersion>1.0.0.2</AssemblyVersion>
<AssemblyFileVersion>1.0.0.2</AssemblyFileVersion>
<Version>1.0.0.2</Version>
<PackageVersion>1.0.0.2</PackageVersion>
<AssemblyVersion>1.0.0.3</AssemblyVersion>
<AssemblyFileVersion>1.0.0.3</AssemblyFileVersion>
<Version>1.0.0.3</Version>
<PackageVersion>1.0.0.3</PackageVersion>
<Authors>dimonovdd</Authors>
<Owners>dimonovdd</Owners>
<PackageProjectUrl>https://github.com/dimonovdd/Xamarin.DateTimePopups</PackageProjectUrl>
Expand Down
11 changes: 9 additions & 2 deletions DateTimePopups/DateTimePopups.ios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@ public static partial class DateTimePopups
{
var tcs = new TaskCompletionSource<DateTime?>();

DateTime defaultDate = selectedDate ?? DateTime.Now;

if (defaultDate.Kind == DateTimeKind.Unspecified)
{
defaultDate = DateTime.SpecifyKind(defaultDate, DateTimeKind.Local);
}

var dialog = new DatePickerDialog(useLocalizedButtons: true);
dialog.Show(
null,
isTime ? UIDatePickerMode.Time : UIDatePickerMode.Date,
(date) => tcs.TrySetResult(date),
selectedDate ?? DateTime.Now,
defaultDate,
maxDate,
minDate,
() => tcs.TrySetResult(null),
Platform.getCurrentViewFunc);
Platform.getCurrentViewFunc);

return tcs.Task;
}
Expand Down

0 comments on commit 1977d62

Please sign in to comment.