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
This commit is contained in:
michelvaldrighi 2004-09-14 16:35:58 +00:00
parent fc0583beab
commit d4a6040c66
1 changed files with 17 additions and 4 deletions

View File

@ -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'