Make WordPress Core

Changeset 1657


Ignore:
Timestamp:
09/14/2004 04:35:58 PM (21 years ago)
Author:
michelvaldrighi
Message:

fixed bug #279, and fixed datetime to make it a proper w3cdtf string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/quicktags.js

    r1619 r1657  
    1616}
    1717
     18function zeroise(number, threshold) {
     19    // FIXME: or we could use an implementation of printf in js here
     20    var str = number.toString();
     21    if (number < 0) { str = str.substr(1, str.length) }
     22    while (str.length < threshold) { str = "0" + str }
     23    if (number < 0) { str = '-' + str }
     24    return str;
     25}
     26
    1827var now = new Date();
    19 var datetime = now.getFullYear() + '-' + now.getMonth() + '-' + now.getDate() + 'T' +
    20                 now.getHours() + ':' + now.getMinutes() + ':' +
    21                 now.getSeconds() + '-' + (now.getTimezoneOffset()/60)
    22                 + ':' + '00';
     28var datetime = now.getFullYear() + '-' +
     29                zeroise(now.getMonth() + 1, 2) + '-' +
     30                zeroise(now.getDate(), 2) + 'T' +
     31                zeroise(now.getHours(), 2) + ':' +
     32                zeroise(now.getMinutes(), 2) + ':' +
     33                zeroise(now.getSeconds() ,2) +
     34                // FIXME: we could try handling timezones like +05:30 and the like
     35                zeroise((now.getTimezoneOffset()/60), 2) + ':' + '00';
    2336
    2437edButtons[edButtons.length] =
Note: See TracChangeset for help on using the changeset viewer.