sangltdn / flot

Automatically exported from code.google.com/p/flot
MIT License
0 stars 0 forks source link

Suggestion: Enable leftPad also for months and days #262

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In the formatDate function, the following specifiers are supported:
  %h': hours
  %H': hours (left-padded with a zero)
  %M': minutes (left-padded with a zero)
  %S': seconds (left-padded with a zero)
  %d': day of month (1-31)
  %m': month (1-12)
  %y': year (four digits)
  %b': month name (customizable)

It would be nice to have left-padded versions of months and days.
I suggest to use respectively %N (%M is already taken) and %D.

For months, a workaround is to use %b. For days, I do not see any easy
workaround.

The patch is quite straightforward: two cases should be added to the
following switch (in jquery.flot.js).

                switch (c) {
                case 'h': c = "" + hours; break;
                case 'H': c = leftPad(hours); break;
                case 'M': c = leftPad(d.getUTCMinutes()); break;
                case 'S': c = leftPad(d.getUTCSeconds()); break;
                case 'd': c = "" + d.getUTCDate(); break;
                case 'm': c = "" + (d.getUTCMonth() + 1); break;
                case 'y': c = "" + d.getUTCFullYear(); break;
                case 'b': c = "" + monthNames[d.getUTCMonth()]; break;
                case 'p': c = (isAM) ? ("" + "am") : ("" + "pm"); break;
                case 'P': c = (isAM) ? ("" + "AM") : ("" + "PM"); break;
                }

==
                case 'D': c = leftPad(d.getUTCDate()); break;
                case 'N': c = leftPad((d.getUTCMonth() + 1)); break;
==

Best Regards,
François

Original issue reported on code.google.com by francois.maurel@gmail.com on 17 Nov 2009 at 9:03

GoogleCodeExporter commented 9 years ago
Hi!

This has been open for very long - I just checked the source for Flot 0.7 and 
there's a generic 0 you can add (so for instance %0m). So I guess that fixes 
this. Thanks for taking the time to report it long time ago anyway.

Original comment by olau%iol...@gtempaccount.com on 28 Apr 2011 at 4:41