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

localized %X without seconds #34

Closed
ITsvetkoFF opened this issue Aug 31, 2017 · 1 comment
Closed

localized %X without seconds #34

ITsvetkoFF opened this issue Aug 31, 2017 · 1 comment

Comments

@ITsvetkoFF
Copy link

ITsvetkoFF commented Aug 31, 2017

Basically I am wondering if there is a non-hacky way in d3 time format to show localized pair of Hours:Minutes (to get 18:03 in German locale and 6:03 PM in US locale)
As I see, moment.js has something like

longDateFormat : {
        LT : 'HH:mm', // <----- this is what I can not find in D3.js
        LTS : 'HH:mm:ss',
        L : 'DD/MM/YYYY',
        LL : 'D MMMM YYYY',
        LLL : 'D MMMM YYYY HH:mm',
        LLLL : 'dddd D MMMM YYYY HH:mm'
    },

I do not suggest to mimic moment behavior, but time without seconds is pretty useful for time charts, where seconds may not be useful. This localized hh:mm pair can be easily used in the localized multiFormat function as formatHour

@mbostock
Copy link
Member

mbostock commented Oct 9, 2017

It seems that every current locale is either %H:%M:%S or %-I:%M:%S %p, so you could just use %H:%M or %-I:%M %p as appropriate. If that feels like a hack, I think we’d have to introduce a new field, say timeMinutes to the locale definition to make the desired localized definition explicit.

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

No branches or pull requests

2 participants