]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 405898: Date/Time Fields should accept times like H:MM
authormkanat%bugzilla.org <>
Fri, 28 Dec 2007 04:39:27 +0000 (04:39 +0000)
committermkanat%bugzilla.org <>
Fri, 28 Dec 2007 04:39:27 +0000 (04:39 +0000)
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit

Bugzilla/Util.pm
js/field.js

index 4d702f02e9b41414939892e6e1ec78921b32c1fc..1471295fc348c2d2ef043e49069ceef30ecb2004 100644 (file)
@@ -476,8 +476,8 @@ sub validate_time {
     my $ts = str2time($time);
     if ($ts) {
         $time2 = time2str("%H:%M:%S", $ts);
-        if (trim($time) =~ /^\d\d:\d\d$/) {
-            $time .= ':00';
+        if ($time =~ /^(\d{1,2}):(\d\d)(?::(\d\d))?$/) {
+            $time = sprintf("%02d:%02d:%02d", $1, $2, $3 || 0);
         }
     }
     my $ret = ($ts && $time eq $time2);
index 97f1cb7a18cf3cbe20798cdb4e2457817cecd984..ca58329f45bf657988211c65b1ff1c5941a58c1d 100644 (file)
@@ -85,7 +85,7 @@ function setFieldFromCalendar(type, args, date_field) {
 
     // We can't just write the date straight into the field, because there 
     // might already be a time there.
-    var timeRe = /(\d\d):(\d\d)(?::(\d\d))?/;
+    var timeRe = /\b(\d{1,2}):(\d\d)(?::(\d\d))?/;
     var currentTime = timeRe.exec(date_field.value);
     var d = new Date(setDate[0], setDate[1] - 1, setDate[2]);
     if (currentTime) {
@@ -104,9 +104,6 @@ function setFieldFromCalendar(type, args, date_field) {
     var dateStr = year + '-' + month  + '-' + day;
 
     if (currentTime) {
-        var hours = d.getHours();
-        if (hours < 10) hours = '0' + String(hours);
-        d.setHours(hours);
         var minutes = d.getMinutes();
         if (minutes < 10) minutes = '0' + String(minutes);
         var seconds = d.getSeconds();
@@ -114,7 +111,7 @@ function setFieldFromCalendar(type, args, date_field) {
             seconds = '0' + String(seconds);
         }
 
-        dateStr = dateStr + ' ' + hours + ':' + minutes;
+        dateStr = dateStr + ' ' + d.getHours() + ':' + minutes;
         if (seconds) dateStr = dateStr + ':' + seconds;
     }