Eonasdan / MomentSharp

MomentJs port to C#

Home Page:http://eonasdan.github.io/MomentSharp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Would be great per moments.js if one could provide a .Format string like "LTS" directly...

Simonl9l opened this issue · comments

please see docs here

there's this:

LongDateFormat = new LongDateFormat

Yes found that in the code, but how does one selectively invoke it...docs are not clear.

It's been 6 years since I wrote this and I'm surprised people are actually using it lol. I'm looking at the code again and I think the reason I didn't include a "format" function is because the native DateTime object already provides this. That said I think you could do this: m.DateTime().ToString(m.Language.LongDateFormat.Lts) where m = new Moment().

Let me know if that helps.

CurrentlyI've taken a private fork and made it DotNet Standard. (that Framework 3.5). The JS original would just take format strings (like TLS) so if you have a use case where users profile the frame for their data the .Format("LTS") etc. method
is useful.

The logic as basically good and reusable, and save reinventing, the JS original is widely popular, and is Numerals.js and Humaize.js. the latter DotNet port is great, and have also privately forked the Numerals port out there and added the "bytes" formatter.

Having at least at latest DotNet versions might encourage more users if that is what you want to do...

If I get the time at some point I can look to push my fork back as a pull request...

Yeah if I had time, I'd rewrite it to use .net 5 and probably provide extensions to DateTime instead of creating a new object. I'm currently putting in a lot of overtime in my regular job and I'm working on a new version of my date picker. If there's interest, I could add a rewrite of this to my long term side project planning