Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
[Fixes #4633] Datetime? and DateTimeOffset? values on InputTagHelper …
Browse files Browse the repository at this point in the history
…are not rendered correctly.
  • Loading branch information
javiercn committed May 20, 2016
1 parent ee2a591 commit 230a13d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Microsoft.AspNetCore.Mvc.TagHelpers/InputTagHelper.cs
Expand Up @@ -356,7 +356,7 @@ private string GetFormat(ModelExplorer modelExplorer, string inputTypeHint, stri
else if (_rfc3339Formats.TryGetValue(inputType, out rfc3339Format) &&
ViewContext.Html5DateRenderingMode == Html5DateRenderingMode.Rfc3339 &&
!modelExplorer.Metadata.HasNonDefaultEditFormat &&
(typeof(DateTime) == modelExplorer.ModelType || typeof(DateTimeOffset) == modelExplorer.ModelType))
(typeof(DateTime) == modelExplorer.Metadata.UnderlyingOrModelType || typeof(DateTimeOffset) == modelExplorer.Metadata.UnderlyingOrModelType))
{
// Rfc3339 mode _may_ override EditFormatString in a limited number of cases e.g. EditFormatString
// must be a default format (i.e. came from a built-in [DataType] attribute).
Expand Down
Expand Up @@ -854,6 +854,9 @@ public async Task ProcessAsync_CallsGenerateCheckBox_WithExpectedParameters()
[InlineData("DateTimeLocal", Html5DateRenderingMode.Rfc3339, "{0:yyyy-MM-ddTHH:mm:ss.fff}", "datetime-local")]
[InlineData("Time", Html5DateRenderingMode.CurrentCulture, "{0:t}", "time")] // Format from [DataType].
[InlineData("Time", Html5DateRenderingMode.Rfc3339, "{0:HH:mm:ss.fff}", "time")]
[InlineData("NullableDate", Html5DateRenderingMode.Rfc3339, "{0:yyyy-MM-dd}", "date")]
[InlineData("NullableDateTime", Html5DateRenderingMode.Rfc3339, "{0:yyyy-MM-ddTHH:mm:ss.fffK}", "datetime")]
[InlineData("NullableDateTimeOffset", Html5DateRenderingMode.Rfc3339, "{0:yyyy-MM-ddTHH:mm:ss.fffK}", "datetime")]
public async Task ProcessAsync_CallsGenerateTextBox_AddsExpectedAttributesForRfc3339(
string propertyName,
Html5DateRenderingMode dateRenderingMode,
Expand Down Expand Up @@ -996,6 +999,13 @@ private class Model

public DateTimeOffset DateTimeOffset { get; set; }

[DataType(DataType.Date)]
public DateTime? NullableDate { get; set; }

public DateTime? NullableDateTime { get; set; }

public DateTimeOffset? NullableDateTimeOffset { get; set; }

[DataType("datetime-local")]
public DateTime DateTimeLocal { get; set; }

Expand Down

0 comments on commit 230a13d

Please sign in to comment.