Commit 120a8d0b authored by olau@iola.dk's avatar olau@iola.dk

Support zero left-padding month/day in timestamps


git-svn-id: https://flot.googlecode.com/svn/trunk@236 1e0a6537-2640-0410-bfb7-f154510ff394
parent e448280e
......@@ -404,6 +404,10 @@ specifiers are supported
%p: am/pm, additionally switches %h/%H to 12 hour instead of 24
%P: AM/PM (uppercase version of %p)
Inserting a zero like %0m or %0d means that the specifier will be
left-padded with a zero if it's only single-digit. So %y-%0m-%0d
results in unambigious ISO timestamps like 2007-05-10 (for May 10th).
You can customize the month names with the "monthNames" option. For
instance, for Danish you might specify:
......
......@@ -16,6 +16,8 @@ Changes:
- Navigate plugin now redraws the plot while panning instead of only
after the fact (can be disabled by setting the pan.frameRate option
to null). Issue 235.
- Date formatter now accepts %0m and %0d to get a zero-padded month or
day (issue raised by Maximillian Dornseif).
Bug fixes:
......
......@@ -2090,7 +2090,7 @@
};
var r = [];
var escape = false;
var escape = false, padNext = false;
var hours = d.getUTCHours();
var isAM = hours < 12;
if (monthNames == null)
......@@ -2118,9 +2118,15 @@
case 'b': c = "" + monthNames[d.getUTCMonth()]; break;
case 'p': c = (isAM) ? ("" + "am") : ("" + "pm"); break;
case 'P': c = (isAM) ? ("" + "AM") : ("" + "PM"); break;
case '0': c = ""; padNext = true; break;
}
if (c && padNext) {
c = leftPad(c);
padNext = false;
}
r.push(c);
escape = false;
if (!padNext)
escape = false;
}
else {
if (c == "%")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment