summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Util.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/Util.pm')
-rw-r--r--Bugzilla/Util.pm17
1 files changed, 17 insertions, 0 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index 5c68a9092..ffc2af95a 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -40,6 +40,7 @@ use base qw(Exporter);
diff_arrays diff_strings
trim wrap_comment find_wrap_point
format_time format_time_decimal validate_date
+ validate_time
file_mod_time is_7bit_clean
bz_crypt generate_random_password
validate_email_syntax clean_text
@@ -457,6 +458,22 @@ sub validate_date {
return $ret ? 1 : 0;
}
+sub validate_time {
+ my ($time) = @_;
+ my $time2;
+
+ # $ts is undefined if the parser fails.
+ my $ts = str2time($time);
+ if ($ts) {
+ $time2 = time2str("%H:%M:%S", $ts);
+
+ $time =~ s/(\d+):(\d+?):(\d+?)/$1:$2:$3/;
+ $time2 =~ s/(\d+):(\d+?):(\d+?)/$1:$2:$3/;
+ }
+ my $ret = ($ts && $time eq $time2);
+ return $ret ? 1 : 0;
+}
+
sub is_7bit_clean {
return $_[0] !~ /[^\x20-\x7E\x0A\x0D]/;
}