diff options
author | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-09-30 02:54:55 +0200 |
---|---|---|
committer | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-09-30 02:54:55 +0200 |
commit | 96d709edae39fc961ad96a7e330cd116b35f1408 (patch) | |
tree | 3bcd206a72e4ddce31495bd97276106f9cb064ba /Bugzilla/Util.pm | |
parent | 0aeaae0427e053b67bd65bf0131de9d562744514 (diff) | |
download | bugzilla-96d709edae39fc961ad96a7e330cd116b35f1408.tar.gz bugzilla-96d709edae39fc961ad96a7e330cd116b35f1408.tar.xz |
Bug 573195: Make Bug.get return all of a bug's standard and custom field
information
r=dkl, a=mkanat
Diffstat (limited to 'Bugzilla/Util.pm')
-rw-r--r-- | Bugzilla/Util.pm | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index 6f5686a3b..6f29a1201 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -444,7 +444,7 @@ sub datetime_from { # strptime() counts years from 1900, and months from 0 (January). # We have to fix both values. - my $dt = DateTime->new({ + my %args = ( year => $time[5] + 1900, month => $time[4] + 1, day => $time[3], @@ -452,12 +452,21 @@ sub datetime_from { minute => $time[1], # DateTime doesn't like fractional seconds. # Also, sometimes seconds are undef. - second => int($time[0] || 0), + second => defined($time[0]) ? int($time[0]) : undef, # If a timezone was specified, use it. Otherwise, use the # local timezone. time_zone => Bugzilla->local_timezone->offset_as_string($time[6]) || Bugzilla->local_timezone, - }); + ); + + # If something wasn't specified in the date, it's best to just not + # pass it to DateTime at all. (This is important for doing datetime_from + # on the deadline field, which is usually just a date with no time.) + foreach my $arg (keys %args) { + delete $args{$arg} if !defined $args{$arg}; + } + + my $dt = new DateTime(\%args); # Now display the date using the given timezone, # or the user's timezone if none is given. |