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);
// 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) {
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();
seconds = '0' + String(seconds);
}
- dateStr = dateStr + ' ' + hours + ':' + minutes;
+ dateStr = dateStr + ' ' + d.getHours() + ':' + minutes;
if (seconds) dateStr = dateStr + ':' + seconds;
}