OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Date should be international on OpenIdServerSettings.Edit.cshtml

Open infofromca opened this issue 7 months ago • 11 comments

Describe the bug

 <option value="@certificate.ThumbPrint" data-StoreLocation="@certificate.StoreLocation" data-StoreName="@certificate.StoreName" selected="@(selectedCertificate)">
     @friendlyName [@certificate.NotBefore.ToString("dd/MM/yy") - @certificate.NotAfter.ToString("dd/MM/yy")] @certificate.Subject
 </option>

Orchard Core version

latest main

To Reproduce

Expected behavior

Logs and screenshots

infofromca avatar Sep 06 '25 23:09 infofromca

Please highlight what you want to change/changed in the code snippet.

Piedone avatar Sep 10 '25 23:09 Piedone

ToString("dd/MM/yy")

infofromca avatar Sep 11 '25 04:09 infofromca

That's the current code. What do you want to change it to?

Piedone avatar Sep 11 '25 16:09 Piedone

ISO

Thank you. Yours

GUANG ZHENG (Andy)

289-577-8554

On Thu, Sep 11, 2025, 12:10 Zoltán Lehóczky @.***> wrote:

Piedone left a comment (OrchardCMS/OrchardCore#18319) https://github.com/OrchardCMS/OrchardCore/issues/18319#issuecomment-3281654010

That's the current code. What do you want to change it to?

— Reply to this email directly, view it on GitHub https://github.com/OrchardCMS/OrchardCore/issues/18319#issuecomment-3281654010, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACIVS6UFZMIYVQMX4OFLSD3SGNHTAVCNFSM6AAAAACF2DGUW2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEOBRGY2TIMBRGA . You are receiving this because you authored the thread.Message ID: @.***>

infofromca avatar Sep 11 '25 17:09 infofromca

We should do what ContentsMeta_SummaryAdmin does:

https://github.com/OrchardCMS/OrchardCore/blob/fe7e2a912ae841614109e5883246278d1ca0fdc2/src/OrchardCore.Modules/OrchardCore.Contents/Views/ContentsMeta_SummaryAdmin.cshtml

Piedone avatar Sep 11 '25 17:09 Piedone

IT IS BETTER THAT there is a common ( Extension) method globally.

infofromca avatar Sep 12 '25 00:09 infofromca

It's not clear to me why you'd want to use ISO 8601 here (it's purely a GUI thing, so there's no interop/round-trip concern in that case).

@Piedone I'm not even sure what's done in ContentsMeta_SummaryAdmin.cshtml is the right approach.

IMHO, it would be better to just use a well-known format like f or g - or F or G when you need seconds - so that the date can be simply rendered using the rules applicable to the current culture/user locale: https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tostring?view=net-8.0#system-datetime-tostring(system-string-system-iformatprovider)

kevinchalet avatar Sep 15 '25 13:09 kevinchalet

Don't be confused by the format string here:

https://github.com/OrchardCMS/OrchardCore/blob/fe7e2a912ae841614109e5883246278d1ca0fdc2/src/OrchardCore.Modules/OrchardCore.Contents/Views/ContentsMeta_SummaryAdmin.cshtml#L5

That's not actually affecting the UI display of the TimeSpan. That's handled eventually here: https://github.com/OrchardCMS/OrchardCore/blob/34ae4d8a53b98520d8df6375a8a9161b45c47635/src/OrchardCore/OrchardCore.DisplayManagement/Shapes/DateTimeShapes.cs#L34

Alternatively, we could use the DateTime shape, which does localization:

https://github.com/OrchardCMS/OrchardCore/blob/34ae4d8a53b98520d8df6375a8a9161b45c47635/src/OrchardCore/OrchardCore.DisplayManagement/Shapes/DateTimeShapes.cs#L117

Piedone avatar Sep 15 '25 20:09 Piedone

Don't be confused by the format string here:

Haha, yeah, I definitely got confused: it's indeed only used for the datetime attribute of the <time> node, for which an ISO-formatted date is the best (in that case, o could be used to avoid the manual format).

kevinchalet avatar Sep 18 '25 09:09 kevinchalet

I filed this issue since this is related.

I suggest we use a localized "format" in this cshtml since the DateTime shape would only be able to render it with the long date time.

@friendlyName [@certificate.NotBefore.ToString(S["dd/MM/yy"]) - @certificate.NotAfter.ToString(S["dd/MM/yy"])] @certificate.Subject

Note that LocalizedString has a default conversion to string by returning the .Value.

sebastienros avatar Sep 18 '25 17:09 sebastienros

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

github-actions[bot] avatar Sep 18 '25 17:09 github-actions[bot]