Fable icon indicating copy to clipboard operation
Fable copied to clipboard

Fix for #1593 added some date tostring options

Open voronoipotato opened this issue 7 years ago • 9 comments
trafficstars

Needs some test cases and some testing. I haven't even built fable yet because I've not gotten that far yet but this is where I am right now.

voronoipotato avatar Oct 06 '18 06:10 voronoipotato

https://github.com/fable-compiler/Fable/issues/1593

voronoipotato avatar Oct 06 '18 06:10 voronoipotato

I guess feel free to close this PR

voronoipotato avatar Oct 07 '18 17:10 voronoipotato

Thanks for your PR @voronoipotato! Maybe we don't need to close it in full, what's in the PR, only localization? I think it'll be difficult to support Globalization as in .NET because it's quite a big amount of work and that may increase the bundle sizes. For the same reasons, I'd prefer to avoid external dependencies in fable-core (like moment-js), but we can discuss about that.

alfonsogarciacaro avatar Oct 08 '18 13:10 alfonsogarciacaro

I'll reopen for now to see if anything may be useful. I wouldn't say that it was "for" globalization but rather some of the formatting does not take into consideration other cultures. The goal I had in doing this PR was to make copy pasting F# into fable just a little bit easier but I did have concerns about it only being useful for westerners potentially mostly for Americans (I know very little about other cultures).

voronoipotato avatar Oct 08 '18 21:10 voronoipotato

I added tostring options with the intention of improving compatibility with Core. I added (f: milliseconds) , (t: AM/PM), dddd Weekdays (english), ddd Weekdays Short (english), mmmm Months (english), mmm Months Short (english), in addition I added several single letter tostring options. d,D,f,F,g,G,m,M,t,T,U . The single letter ToString format for dates exists as a convenience and allows the user to quickly format a date in a useful way. Date.ToString("d") for example is equivalent to Date.ToString("M/d/yyyy") however you can see how this may be less useful for someone who doesn't use middle endian dates. There definitely are bits that would require no localization, and many of these are the default if I'm not mistaken in .Net, which wouldn't surprise me given that the Microsoft is an American company. However I am an American, and have never programmed anything in .Net that needed localization so I'm not exactly any authority on the subject.

voronoipotato avatar Oct 08 '18 21:10 voronoipotato

Perhaps later we can move all the date stuff into Date.ts, since Util.ts is getting quite big. A few tests to cover the new options will go a long way. "A test a day keeps the doctor away."

ncave avatar Oct 09 '18 00:10 ncave

That sounds wise ncave. I'll give it a shot.

voronoipotato avatar Oct 23 '18 13:10 voronoipotato

Hi @voronoipotato! What's the status of this? Will you include some tests to see what the PR is trying to solve? Thank you!

alfonsogarciacaro avatar Dec 12 '18 09:12 alfonsogarciacaro

This isn't needed anymore is it? I am dumb as bricks and missed the ping for a few years now.

voronoipotato avatar Oct 11 '21 22:10 voronoipotato

This PR being quite old I think we can close it for now.

There is https://github.com/fable-compiler/Fable/issues/3692 which tracks the task to improve supported format for DateTime. If someone want to revive it then can either adapt the original mscord code or take inspiration from this PR too.

MangelMaxime avatar Jan 24 '24 22:01 MangelMaxime