From bffc2eea9fdfd0521cd60c35c41d35b822b5755c Mon Sep 17 00:00:00 2001 From: Mark Cote Date: Fri, 15 Jun 2012 07:16:15 -0400 Subject: [PATCH] If found, use strftime function of date objects instead of built-in formatting. --- jquery.flot.time.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jquery.flot.time.js b/jquery.flot.time.js index d94d574..a9876b1 100644 --- a/jquery.flot.time.js +++ b/jquery.flot.time.js @@ -15,6 +15,9 @@ for details. // Returns a string with the date d formatted according to fmt. // A subset of the Open Group's strftime format is supported. function formatDate(d, fmt, monthNames, dayNames) { + if (typeof d.strftime == "function") { + return d.strftime(fmt); + } var leftPad = function(n, pad) { n = "" + n; pad = "" + (pad == null ? "0" : pad); @@ -82,11 +85,14 @@ for details. targetMethod) { sourceObj[sourceMethod] = function() { return targetObj[targetMethod].apply(targetObj, arguments); - } + }; }; var utc = { date: d }; + // support strftime, if found + if (d.strftime != undefined) + addProxyMethod(utc, "strftime", d, "strftime"); addProxyMethod(utc, "getTime", d, "getTime"); addProxyMethod(utc, "setTime", d, "setTime"); var props = [ "Date", "Day", "FullYear", "Hours", "Milliseconds", "Minutes", "Month", "Seconds" ];