From d4a6040c66e35c9de5e29ac36265bbba690aa690 Mon Sep 17 00:00:00 2001 From: michelvaldrighi Date: Tue, 14 Sep 2004 16:35:58 +0000 Subject: [PATCH] fixed bug #279, and fixed datetime to make it a proper w3cdtf string git-svn-id: http://svn.automattic.com/wordpress/trunk@1657 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/quicktags.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/wp-admin/quicktags.js b/wp-admin/quicktags.js index ada23ab2e9..80c724aafe 100644 --- a/wp-admin/quicktags.js +++ b/wp-admin/quicktags.js @@ -15,11 +15,24 @@ function edButton(id, display, tagStart, tagEnd, access, open) { this.open = open; // set to -1 if tag does not need to be closed } +function zeroise(number, threshold) { + // FIXME: or we could use an implementation of printf in js here + var str = number.toString(); + if (number < 0) { str = str.substr(1, str.length) } + while (str.length < threshold) { str = "0" + str } + if (number < 0) { str = '-' + str } + return str; +} + var now = new Date(); -var datetime = now.getFullYear() + '-' + now.getMonth() + '-' + now.getDate() + 'T' + - now.getHours() + ':' + now.getMinutes() + ':' + - now.getSeconds() + '-' + (now.getTimezoneOffset()/60) - + ':' + '00'; +var datetime = now.getFullYear() + '-' + + zeroise(now.getMonth() + 1, 2) + '-' + + zeroise(now.getDate(), 2) + 'T' + + zeroise(now.getHours(), 2) + ':' + + zeroise(now.getMinutes(), 2) + ':' + + zeroise(now.getSeconds() ,2) + + // FIXME: we could try handling timezones like +05:30 and the like + zeroise((now.getTimezoneOffset()/60), 2) + ':' + '00'; edButtons[edButtons.length] = new edButton('ed_strong'