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

There is no single-digit formatter for month #8150

Closed
glajchs opened this Issue Apr 9, 2018 · 6 comments

Comments

Projects
None yet
4 participants
@glajchs

glajchs commented Apr 9, 2018

Expected behaviour

I can format a date like (4/3) for April 3rd without requiring a custom formatter.

Actual behaviour

The default formats April 3rd like (04/3), which looks very weird. I can double-digit pad the day to make it look like (04/03), but that still looks bad.

Live demo with steps to reproduce

http://jsfiddle.net/LLExL/11754/

Product version

6.0.7

Affected browser(s)

All

@sebastianbochan

This comment has been minimized.

Contributor

sebastianbochan commented Apr 10, 2018

Hi @glajchs
The dateformat is a subset of the formats for PHP's strftime function.

If you need to have custom one, you should use formatter.

@pawelfus

This comment has been minimized.

Contributor

pawelfus commented Apr 10, 2018

We don't have to use formatter, we can keep format option and simply define our own format for month numbers without leading zeros, API: https://api.highcharts.com/class-reference/Highcharts.html#.dateFormats

Demo: http://jsfiddle.net/BlackLabel/LLExL/11801/

PS: In my opinion 02/30, 03/01 and 03/04 looks better than 2/30, 3/1 and 3/4 which looks like fractions.

@pawelfus pawelfus added the Not a bug label Apr 10, 2018

@TorsteinHonsi

This comment has been minimized.

Collaborator

TorsteinHonsi commented Apr 10, 2018

I agree with @glajchs, we should support this. In some cultures (like my own), it is common to write 10/3 for April 10th and so on. I'm surprised PHP doesn't have a symbol for this.

Do you have any suggestion for which letter to use? Any conventions out there in other programming languages?

@pawelfus

This comment has been minimized.

Contributor

pawelfus commented Apr 10, 2018

How about %j ? Like PHP, but from date: http://php.net/manual/en/function.date.php

@sebastianbochan

This comment has been minimized.

Contributor

sebastianbochan commented Apr 11, 2018

But the %j in returns global day from a year, not month.

http://www.php.net/manual/en/function.strftime.php

@glajchs

This comment has been minimized.

glajchs commented May 26, 2018

I have a suggestion for what the new "month # without leading zero" variable should be, which is "%o". Highcharts uses a subset of the PHP API, as linked above. In the PHP API, the standard seems to be to use the next available letter in the alphabet, in lower case, when providing the non-leading-zeros-prefixed version of a value. For instance the leading-zero-prefixed 24 hour value is "%H", and the non-leading-zero-prefixed version of the 24 hour value is "%k". It's not "%h" because that's already taken, and it's not "%i", or "%j" because those are already taken.

Since our 2 digit month is "%m", and "%M" is already taken, the next value could be "%n", but I'd advise against that since you're borrowing a subset from the PHP API, and in the PHP API "%n" is newline char (even though highcharts doesn't support this).

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