summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Util.pm
diff options
context:
space:
mode:
authorjocuri%softhome.net <>2005-01-16 22:36:02 +0100
committerjocuri%softhome.net <>2005-01-16 22:36:02 +0100
commitc1a8053e98fa659ffda19fae799423c1762dbd10 (patch)
tree73c2a248c499ee3b7a811d3dbca07c14078e3069 /Bugzilla/Util.pm
parentce3c5ed7f0c8c4426b3717c169674edfe7a16556 (diff)
downloadbugzilla-c1a8053e98fa659ffda19fae799423c1762dbd10.tar.gz
bugzilla-c1a8053e98fa659ffda19fae799423c1762dbd10.tar.xz
Patch for bug 103636: Support specifying a date on which a bug is expected to be resolved; patch by Alexandre Michetti Manduca <michetti@grad.icmc.usp.br>, r=jouni, a=myk.
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 142866912..b832d1698 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -36,6 +36,9 @@ use base qw(Exporter);
format_time format_time_decimal);
use Bugzilla::Config;
+use Bugzilla::Error;
+use Date::Parse;
+use Date::Format;
# This is from the perlsec page, slightly modifed to remove a warning
# From that page:
@@ -220,6 +223,20 @@ sub format_time_decimal {
return $newtime;
}
+sub ValidateDate {
+ my ($date, $format) = @_;
+
+ my $ts = str2time($date);
+ my $date2 = time2str("%Y-%m-%d", $ts);
+
+ $date =~ s/(\d+)-0*(\d+?)-0*(\d+?)/$1-$2-$3/;
+ $date2 =~ s/(\d+)-0*(\d+?)-0*(\d+?)/$1-$2-$3/;
+
+ if ($date ne $date2) {
+ ThrowUserError('illegal_date', {date => $date, format => $format});
+ }
+}
+
1;
__END__