sachatrauwaen / OpenContent

Structured Content editing for DNN (Dotnetnuke)
46 stars 25 forks source link

{{formatDateTime publishstartdate "dd-MM-yyyy" }} issue #73

Open Timo-Breumelhof opened 5 years ago

Timo-Breumelhof commented 5 years ago

I noticed that in a server side template I need to use this:

{{formatDateTime publishstartdate "dd-MM-yyyy"}}

And in a Client side template: {{formatDateTime publishstartdate "DD-MM-YYYY"}}

To get 15-05-2019 as a result.

If i use {{formatDateTime publishstartdate "DD-MM-YYYY"}} in a server side template, the result is DD-15-yyyy

This is with OC 04.01.00

sachatrauwaen commented 5 years ago

The problem is that server side it use dot.Net datetime format and is hardcoded.

And clientside, it use helpers defined in the template.js and by default use momentjs wich use other format strings. If you can find a js library that match dotnet format string, we can harmonize...

Timo-Breumelhof commented 5 years ago

ah, ok

Timo-Breumelhof commented 5 years ago

did find a C# option ;-) https://gist.github.com/spooky/5546120

Timo-Breumelhof commented 5 years ago

Maybe this plugin is an option, seems to do the same: https://momentjs.com/docs/#/plugins/jdateformatparser/ ?

sachatrauwaen commented 5 years ago

My preference goes to do the transformation in js because the dotNet part is hardcoded and the documentation is based on the dotNet format.

We can start doing it in the articles templates js file.

Timo-Breumelhof commented 5 years ago

I think the JAVA format converter could work, right?

b-creative commented 4 years ago

The fact that {{formatDateTime Startdatum "D MMM" "nl-NL"}}, in a clientside template, does NOT give a desired result is related to this? It returns 20 May and the desired result is 20 mei. Is there a solution or workaround?

Timo-Breumelhof commented 4 years ago

@b-creative I don't think it is

b-creative commented 4 years ago

Adding {{registerscript "/DesktopModules/OpenContent/js/lib/moment/locale/nl.js"}} in template.hbs and changing the call in item.hbs into {{formatDateTime Startdatum "D MMM" "nl"}} helped me!