Skip to content

Commit b2ddb2a

Browse files
Revert "Changes on copilot review - use en-US culture for test in DateFieldTagHelperFixture.cs, extracting the culture selection logic into a separate variable for better readability in DateTagHelper.cs"
This reverts commit 979e588.
1 parent 5477975 commit b2ddb2a

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/Sitecore.AspNetCore.SDK.RenderingEngine/TagHelpers/Fields/DateTagHelper.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
6767

6868
CultureInfo culture = !string.IsNullOrWhiteSpace(Culture) ? CultureInfo.CreateSpecificCulture(Culture) : CultureInfo.CurrentCulture;
6969

70-
CultureInfo formatCulture = !string.IsNullOrWhiteSpace(Culture) ? culture : CultureInfo.InvariantCulture;
71-
72-
string formattedDate = !string.IsNullOrWhiteSpace(DateFormat) ? field.Value.ToString(DateFormat, formatCulture) : field.Value.ToString(culture);
70+
string formattedDate = !string.IsNullOrWhiteSpace(DateFormat) ? field.Value.ToString(DateFormat, !string.IsNullOrWhiteSpace(Culture) ? culture : CultureInfo.InvariantCulture) : field.Value.ToString(culture);
7371

7472
HtmlString html = outputEditableMarkup ? new HtmlString(field.EditableMarkup) : new HtmlString(formattedDate);
7573

tests/Sitecore.AspNetCore.SDK.RenderingEngine.Integration.Tests/Fixtures/TagHelpers/DateFieldTagHelperFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public DateFieldTagHelperFixture()
4141
app.UseRouting();
4242
app.UseRequestLocalization(options =>
4343
{
44-
var culture = new CultureInfo("en-US");
44+
var culture = new CultureInfo("da-DK");
4545
options.DefaultRequestCulture = new RequestCulture(culture);
4646
options.SupportedCultures = [culture];
4747
options.SupportedUICultures = [culture];
@@ -103,7 +103,7 @@ public async Task DateTagHelper_GeneratesProperDate()
103103
// Assert
104104
sectionNode.ChildNodes[1].InnerHtml.Should().Be("05/04/2012");
105105
sectionNode.ChildNodes[3].InnerHtml.Should().Be("05/04/2012 00:00:00");
106-
sectionNode.ChildNodes[5].InnerHtml.Should().Be(TestConstants.DateTimeValue.ToString(new CultureInfo("en-US")));
106+
sectionNode.ChildNodes[5].InnerHtml.Should().Be(TestConstants.DateTimeValue.ToString(new CultureInfo("da-DK")));
107107
sectionNode.ChildNodes[9].InnerHtml.Should().Contain("04.05.2012");
108108
}
109109

0 commit comments

Comments
 (0)