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 ...@@ -404,6 +404,10 @@ specifiers are supported
%p: am/pm, additionally switches %h/%H to 12 hour instead of 24 %p: am/pm, additionally switches %h/%H to 12 hour instead of 24
%P: AM/PM (uppercase version of %p) %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 You can customize the month names with the "monthNames" option. For
instance, for Danish you might specify: instance, for Danish you might specify:
......
...@@ -16,6 +16,8 @@ Changes: ...@@ -16,6 +16,8 @@ Changes:
- Navigate plugin now redraws the plot while panning instead of only - Navigate plugin now redraws the plot while panning instead of only
after the fact (can be disabled by setting the pan.frameRate option after the fact (can be disabled by setting the pan.frameRate option
to null). Issue 235. 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: Bug fixes:
......
...@@ -2090,7 +2090,7 @@ ...@@ -2090,7 +2090,7 @@
}; };
var r = []; var r = [];
var escape = false; var escape = false, padNext = false;
var hours = d.getUTCHours(); var hours = d.getUTCHours();
var isAM = hours < 12; var isAM = hours < 12;
if (monthNames == null) if (monthNames == null)
...@@ -2118,8 +2118,14 @@ ...@@ -2118,8 +2118,14 @@
case 'b': c = "" + monthNames[d.getUTCMonth()]; break; case 'b': c = "" + monthNames[d.getUTCMonth()]; break;
case 'p': c = (isAM) ? ("" + "am") : ("" + "pm"); break; case 'p': c = (isAM) ? ("" + "am") : ("" + "pm"); 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); r.push(c);
if (!padNext)
escape = false; escape = false;
} }
else { else {
......
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