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

[Fixes #4102] DefaultHtmlGenerator should attempt to properly format values for <input type="date"> and <input type="time"> #4250

Merged
merged 1 commit into from
Mar 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
public enum Html5DateRenderingMode
{
/// <summary>
/// Render date and time values according to the current culture's ToString behavior.
/// Render date and time values as Rfc3339 compliant strings to support HTML5 date and time types of input
/// elements.
/// </summary>
CurrentCulture = 0,
Rfc3339 = 0,

/// <summary>
/// Render date and time values as Rfc3339 compliant strings to support HTML5 date and time types of input
/// elements.
/// Render date and time values according to the current culture's ToString behavior.
/// </summary>
Rfc3339,
CurrentCulture,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
<div>
<label class="order" for="HtmlEncode[[ShippingDateTime]]">HtmlEncode[[ShippingDateTime]]</label>
<input type="HtmlEncode[[datetime-local]]" data-val="HtmlEncode[[true]]" data-val-required="HtmlEncode[[The ShippingDateTime field is required.]]" id="HtmlEncode[[ShippingDateTime]]" name="HtmlEncode[[ShippingDateTime]]" value="HtmlEncode[[01/01/0001 00:00:00]]" />
<input type="HtmlEncode[[datetime-local]]" data-val="HtmlEncode[[true]]" data-val-required="HtmlEncode[[The ShippingDateTime field is required.]]" id="HtmlEncode[[ShippingDateTime]]" name="HtmlEncode[[ShippingDateTime]]" value="HtmlEncode[[0001-01-01T00:00:00.000]]" />
</div>
<div>
<label class="order" for="HtmlEncode[[Products]]">HtmlEncode[[Products]]</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
<div>
<label class="order" for="ShippingDateTime">ShippingDateTime</label>
<input type="datetime-local" data-val="true" data-val-required="The ShippingDateTime field is required." id="ShippingDateTime" name="ShippingDateTime" value="01/01/0001 00:00:00" />
<input type="datetime-local" data-val="true" data-val-required="The ShippingDateTime field is required." id="ShippingDateTime" name="ShippingDateTime" value="0001-01-01T00:00:00.000" />
</div>
<div>
<label class="order" for="Products">Products</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,10 @@ public void Editor_FindsViewDataMember()

// DateTime-local is not special-cased unless using Html5DateRenderingMode.Rfc3339.
[Theory]
[InlineData("date", "{0:d}", "02/01/2000")]
[InlineData("datetime", null, "02/01/2000 03:04:05 +00:00")]
[InlineData("datetime-local", null, "02/01/2000 03:04:05 +00:00")]
[InlineData("time", "{0:t}", "03:04")]
[InlineData("date", "{0:d}", "2000-01-02")]
[InlineData("datetime", null, "2000-01-02T03:04:05.006+00:00")]
[InlineData("datetime-local", null, "2000-01-02T03:04:05.006")]
[InlineData("time", "{0:t}", "03:04:05.006")]
[ReplaceCulture]
public void Editor_FindsCorrectDateOrTimeTemplate(string dataTypeName, string editFormatString, string expected)
{
Expand Down