Sha256: 1822c2e7a414b345ba4404676e9ae1b8ad0645e9ade9fbcb93c59daa3b2479e8

Contents?: true

Size: 1.05 KB

Versions: 21

Compression:

Stored size: 1.05 KB

Contents

// International date format (ISO 8601): yyyy-mm-dd
// Including time (no seconds): yyyy-mm-dd HH:MM
Date.prototype.toFormattedString = function(include_time) {
        var hour;
    var str = this.getFullYear() + "-" + Date.padded2(this.getMonth() + 1) + "-" +Date.padded2(this.getDate());
    if (include_time) {
        hour = Date.padded2(this.getHours());
        str += " " + hour + ":" + this.getPaddedMinutes();
    }
    return str;
};

// TODO: take care of timezone offsets
// as the timezone is not displayed in the input,
// this could be tricky (or just unnessesary)
Date.parseFormattedString = function (string) {
   var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})" +
                "([T| ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?" +
                "(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
   var d = string.match(new RegExp(regexp));

   var date = new Date(d[1], 0, 1);

   if (d[3]) { date.setMonth(d[3] - 1); }
   if (d[5]) { date.setDate(d[5]); }
   if (d[7]) { date.setHours(d[7]); }
   if (d[8]) { date.setMinutes(d[8]); }
   return date;
};

Version data entries

21 entries across 20 versions & 6 rubygems

Version Path
calendar_date_select-2.1.2 app/assets/javascripts/calendar_date_select/format_iso_date.js
calendar_date_select-2.1.0 app/assets/javascripts/calendar_date_select/format_iso_date.js
calendar_date_select-2.0.0 app/assets/javascripts/calendar_date_select/format_iso_date.js
calendar_date_select_rails3-1.16.2 public/javascripts/calendar_date_select/format_iso_date.js
calendar_date_select-1.16.4 public/javascripts/calendar_date_select/format_iso_date.js
fat_free_crm-0.11.3 vendor/assets/javascripts/calendar_date_select/format_iso_date.js
fat_free_crm-0.11.2 vendor/assets/javascripts/calendar_date_select/format_iso_date.js
fat_free_crm-0.11.1 vendor/assets/javascripts/calendar_date_select/format_iso_date.js
fat_free_crm-0.11.0 vendor/assets/javascripts/calendar_date_select/format_iso_date.js
webroar-0.7.0 src/admin_panel/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_iso_date.js
webroar-0.7.0 src/admin_panel/public/javascripts/calendar_date_select/format_iso_date.js
webroar-0.6.1 src/admin_panel/public/javascripts/calendar_date_select/format_iso_date.js
calendar_date_select-1.16.3 public/javascripts/calendar_date_select/format_iso_date.js
webroar-0.5.0 src/admin_panel/public/javascripts/calendar_date_select/format_iso_date.js
calendar_date_select-1.16.2 public/javascripts/calendar_date_select/format_iso_date.js
ginkel-calendar_date_select-1.16.1.2 public/javascripts/calendar_date_select/format_iso_date.js
ginkel-calendar_date_select-1.16.1.1 public/javascripts/calendar_date_select/format_iso_date.js
calendar_date_select-1.16.1 public/javascripts/calendar_date_select/format_iso_date.js
calendar_date_select-1.16 public/javascripts/calendar_date_select/format_iso_date.js
tristandunn-calendar_date_select-1.15.0 public/javascripts/calendar_date_select/format_iso_date.js