From c1a8053e98fa659ffda19fae799423c1762dbd10 Mon Sep 17 00:00:00 2001 From: "jocuri%softhome.net" <> Date: Sun, 16 Jan 2005 21:36:02 +0000 Subject: Patch for bug 103636: Support specifying a date on which a bug is expected to be resolved; patch by Alexandre Michetti Manduca , r=jouni, a=myk. --- Bugzilla/Util.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'Bugzilla/Util.pm') 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__ -- cgit v1.2.3-24-g4f1b