Ticket #6483: 0008-Support-European-date-format-for-JavaScript.patch

File 0008-Support-European-date-format-for-JavaScript.patch, 1.7 KB (added by Bastian Kleineidam <calvin@…>, 17 years ago)
  • django/contrib/admin/media/js/core.js

    From fb2168f6a37f474897d5bc69356743b72d9f739d Mon Sep 17 00:00:00 2001
    From: Bastian Kleineidam <calvin@debian.org>
    Date: Fri, 25 Jan 2008 17:23:27 +0100
    Subject: Support European date format for JavaScript
    
    Add support for parsing European date format "DD.MM.YYYY" in
    the JavaScript date routines.
    
    Signed-off-by: Bastian Kleineidam <calvin@debian.org>
    
    diff --git a/django/contrib/admin/media/js/core.js b/django/contrib/admin/media/js/core.js
    index c8d0db6..a3238d0 100644
    a b Date.prototype.getISODate = function() {  
    139139    return this.getCorrectYear() + '-' + this.getTwoDigitMonth() + '-' + this.getTwoDigitDate();
    140140}
    141141
     142Date.prototype.getEuropeanDate = function() {
     143    return this.getTwoDigitDate() + '.' + this.getTwoDigitMonth() + '.' + this.getCorrectYear();
     144}
     145
    142146Date.prototype.getHourMinute = function() {
    143147    return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute();
    144148}
  • django/contrib/admin/media/js/dateparse.js

    diff --git a/django/contrib/admin/media/js/dateparse.js b/django/contrib/admin/media/js/dateparse.js
    index e1c870e..dd06880 100644
    a b var dateParsePatterns = [  
    174174            return d;
    175175        }
    176176    },
     177    // dd.mm.yyyy (European style)
     178    {   re: /(\d{1,2})\.(\d{1,2}).(\d{4})/,
     179        handler: function(bits) {
     180            var d = new Date();
     181            d.setDate(parseInt(bits[1], 10));
     182            d.setMonth(parseInt(bits[2], 10) - 1);
     183            d.setYear(parseInt(bits[3]));
     184            return d;
     185        }
     186    },
    177187];
    178188
    179189function parseDateString(s) {
Back to Top