summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Bug.pm
diff options
context:
space:
mode:
authorGervase Markham <gerv@gerv.net>2013-01-02 18:58:34 +0100
committerGervase Markham <gerv@mozilla.org>2013-01-02 18:58:34 +0100
commit725f2fb7958c6a251efdb056d49063fc4f8da91a (patch)
tree068dd4c94d2a9f7bf3ae85f6019d4c2ba4a67989 /Bugzilla/Bug.pm
parent21b50cba4e08e723f8c2d8e8b5800d0a13e2c180 (diff)
downloadbugzilla-725f2fb7958c6a251efdb056d49063fc4f8da91a.tar.gz
bugzilla-725f2fb7958c6a251efdb056d49063fc4f8da91a.tar.xz
Bug 801664 - Add DATE type for custom fields. r=LpSolit.
Diffstat (limited to 'Bugzilla/Bug.pm')
-rw-r--r--Bugzilla/Bug.pm18
1 files changed, 16 insertions, 2 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index c58fec460..6680ede55 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -146,6 +146,9 @@ sub VALIDATORS {
elsif ($field->type == FIELD_TYPE_DATETIME) {
$validator = \&_check_datetime_field;
}
+ elsif ($field->type == FIELD_TYPE_DATE) {
+ $validator = \&_check_date_field;
+ }
elsif ($field->type == FIELD_TYPE_FREETEXT) {
$validator = \&_check_freetext_field;
}
@@ -233,7 +236,9 @@ use constant NUMERIC_COLUMNS => qw(
);
sub DATE_COLUMNS {
- my @fields = @{ Bugzilla->fields({ type => FIELD_TYPE_DATETIME }) };
+ my @fields = (@{ Bugzilla->fields({ type => [FIELD_TYPE_DATETIME,
+ FIELD_TYPE_DATE] })
+ });
return map { $_->name } @fields;
}
@@ -1983,8 +1988,13 @@ sub _check_field_is_mandatory {
}
}
+sub _check_date_field {
+ my ($invocant, $date) = @_;
+ return _check_datetime_field($invocant, $date, 1);
+}
+
sub _check_datetime_field {
- my ($invocant, $date_time) = @_;
+ my ($invocant, $date_time, $date_only) = @_;
# Empty datetimes are empty strings or strings only containing
# 0's, whitespace, and punctuation.
@@ -1998,6 +2008,10 @@ sub _check_datetime_field {
ThrowUserError('illegal_date', { date => $date,
format => 'YYYY-MM-DD' });
}
+ if ($time && $date_only) {
+ ThrowUserError('illegal_date', { date => $date_time,
+ format => 'YYYY-MM-DD' });
+ }
if ($time && !validate_time($time)) {
ThrowUserError('illegal_time', { 'time' => $time,
format => 'HH:MM:SS' });