-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Date and times formats and conversions fix
- Loading branch information
Showing
7 changed files
with
28 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 22 additions & 13 deletions
35
src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/Date.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
@model object | ||
|
||
@if (Model is DateTime?) | ||
@switch (Model) | ||
{ | ||
var date = (DateTime?)Model; | ||
@Html.TextBox("", (date.HasValue ? date.Value.ToString("yyyy-MM-dd") : string.Empty), new { type = "date", @class = "datePicker form-control" }) | ||
} | ||
case DateTime dateTimeValue: | ||
{ | ||
@Html.TextBox("", dateTimeValue.ToString("yyyy-MM-dd"), new { type = "date", @class = "datePicker form-control" }); | ||
break; | ||
} | ||
|
||
@if (Model is DateTimeOffset?) | ||
{ | ||
var date = (DateTimeOffset?)Model; | ||
@Html.TextBox("", (date.HasValue ? date.Value.ToString("yyyy-MM-dd") : string.Empty), new { type = "date", @class = "datePicker form-control" }) | ||
} | ||
case DateTimeOffset dateTimeOffsetValue: | ||
{ | ||
@Html.TextBox("", dateTimeOffsetValue.ToString("yyyy-MM-dd"), new { type = "date", @class = "datePicker form-control" }); | ||
break; | ||
} | ||
|
||
@if (Model is DateOnly?) | ||
{ | ||
var date = (DateOnly?)Model; | ||
@Html.TextBox("", (date.HasValue ? date.Value.ToString("yyyy-MM-dd") : string.Empty), new { type = "date", @class = "datePicker form-control" }) | ||
case DateOnly dateOnlyValue: | ||
{ | ||
@Html.TextBox("", dateOnlyValue.ToString("yyyy-MM-dd"), new { type = "date", @class = "datePicker form-control" }); | ||
break; | ||
} | ||
|
||
default: | ||
{ | ||
@Html.TextBox("", null, new { type = "date", @class = "datePicker form-control" }) | ||
break; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateOnly.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
@model DateOnly? | ||
@Html.TextBox("", (Model.HasValue ? Model.Value.ToString("O") : string.Empty), new { type = "date", @class = "datePicker form-control" }) | ||
@Html.TextBox("", Model?.ToString("yyyy-MM-dd"), new { type = "date", @class = "datePicker form-control" }) |
2 changes: 1 addition & 1 deletion
2
src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateTime.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
@model DateTime? | ||
@Html.TextBox("", (Model.HasValue ? Model.Value.ToString("s") : string.Empty), new { type = "datetime-local", @class = "datePicker form-control" }) | ||
@Html.TextBox("", Model?.ToLocalTime().ToString("yyyy-MM-ddTHH:mm:ss.fff"), new { type = "datetime-local", @class = "datePicker form-control" }) |
2 changes: 1 addition & 1 deletion
2
src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateTimeOffset.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
@model DateTimeOffset? | ||
@Html.TextBox("", (Model.HasValue ? Model.Value.ToString("s") : string.Empty), new { type = "datetime-local", @class = "datePicker form-control" }) | ||
@Html.TextBox("", Model?.ToLocalTime().ToString("yyyy-MM-ddTHH:mm:ss.fff"), new { type = "datetime-local", @class = "datePicker form-control" }) |
2 changes: 1 addition & 1 deletion
2
src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/TimeOnly.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
@model TimeOnly? | ||
@Html.TextBox("", (Model.HasValue ? Model.Value.ToString("HH:mm:ss") : string.Empty), new { type = "time", @class = "form-control" }) | ||
@Html.TextBox("", Model?.ToString("HH:mm:ss.fff"), new { type = "time", @class = "form-control" }) |
2 changes: 1 addition & 1 deletion
2
src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/TimeSpan.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
@model TimeSpan? | ||
@Html.TextBox("", (Model.HasValue ? Model.Value.ToString("c") : string.Empty), new { type = "time", @class = "form-control" }) | ||
@Html.TextBox("", Model?.Ticks, new { type = "number", @class = "text-box single-line form-control number-form-control", max = Int64.MaxValue, min = Int64.MinValue }) |