Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to get a localised time including seconds #1450

Closed
lukeapage opened this issue Jan 29, 2014 · 5 comments
Closed

No way to get a localised time including seconds #1450

lukeapage opened this issue Jan 29, 2014 · 5 comments

Comments

@lukeapage
Copy link

We mantain a patched version of moment with a new time identifier LTT which is the time in seconds.

Is there any wish to support more localised formats like this? Or allow more general localised formats so that I only need to patch the language file to get this to work?

@ichernev
Copy link
Contributor

May I ask why you need seconds? I haven't come across a good reason to have them in humanly readable timestamps. Also adding them to all formats doesn't seem feasible. Once we get cldr support it will be possible.

@lukeapage
Copy link
Author

We show a grid of events, of which multiple may appear in a minute. We also
have a chart where the x axis can be time and down to the level where
seconds are important. Completely understand if its not a usual usecase.
Look forward to cldr.

@ichernev
Copy link
Contributor

ichernev commented Feb 1, 2014

I assume you're using also multiple languages (otherwise you can just explode the token). In this case you can just do something like:

m.lang('fr') // put the right language here
m._lang._longDateFormat.LT += ':ss'

on initialization, and you'd have a modified LT token (but you won't have the old LT now :)).

Of course you'd need an array of mappings, because adding :ss to the end won't work for all languages, but you have a patch now, so you have the mappings (humanly generated) already.

Its kind of ugly, but much better than patching the code. Also we might add support for adding additional tokens, check #1454 (comment)

@lukeapage
Copy link
Author

We want without too.. so we need 2 time formats (i patch the regex to allow
LTT and add ltt to each language we support). We also need more date
formats too e.g. just month and year as discussed on the other cldr issue -
we currently work around by hardcoding those formats.

I don't like patching code but its currently our only workable solution.

@ichernev
Copy link
Contributor

Closing this. We're not making structural changes to the locale data anymore. With CLDR this would be possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants