diff options
author | mkanat%bugzilla.org <> | 2007-10-24 02:36:51 +0200 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2007-10-24 02:36:51 +0200 |
commit | 16a1c874c190a2726ff8a9e9aadac12a37592023 (patch) | |
tree | 9ea33d5c333ada4c0084a2d0e0871055714a37d4 /Bugzilla/Bug.pm | |
parent | 212433f27ac422f79924d03b5d047236f6cdd308 (diff) | |
download | bugzilla-16a1c874c190a2726ff8a9e9aadac12a37592023.tar.gz bugzilla-16a1c874c190a2726ff8a9e9aadac12a37592023.tar.xz |
Bug 357324: Date/Time Custom Fields
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla/Bug.pm')
-rwxr-xr-x | Bugzilla/Bug.pm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index ed398f0fe..ba66e846f 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -145,6 +145,9 @@ sub VALIDATORS { elsif ($field->type == FIELD_TYPE_MULTI_SELECT) { $validator = \&_check_multi_select_field; } + elsif ($field->type == FIELD_TYPE_DATETIME) { + $validator = \&_check_datetime_field; + } else { $validator = \&_check_freetext_field; } @@ -1240,6 +1243,28 @@ sub _check_work_time { # Custom Field Validators +sub _check_datetime_field { + my ($invocant, $date_time) = @_; + + # Empty datetimes are empty strings or strings only containing + # 0's, whitespace, and punctuation. + if ($date_time =~ /^[\s0[:punct:]]*$/) { + return undef; + } + + $date_time = trim($date_time); + my ($date, $time) = split(' ', $date_time); + if ($date && !validate_date($date)) { + ThrowUserError('illegal_date', { date => $date, + format => 'YYYY-MM-DD' }); + } + if ($time && !validate_time($time)) { + ThrowUserError('illegal_time', { 'time' => $time, + format => 'HH:MM:SS' }); + } + return $date_time +} + sub _check_multi_select_field { my ($invocant, $values, $field) = @_; return [] if !$values; |