Commit 96d709ed authored by Max Kanat-Alexander's avatar Max Kanat-Alexander

Bug 573195: Make Bug.get return all of a bug's standard and custom field

information r=dkl, a=mkanat
parent 0aeaae04
...@@ -444,7 +444,7 @@ sub datetime_from { ...@@ -444,7 +444,7 @@ sub datetime_from {
# strptime() counts years from 1900, and months from 0 (January). # strptime() counts years from 1900, and months from 0 (January).
# We have to fix both values. # We have to fix both values.
my $dt = DateTime->new({ my %args = (
year => $time[5] + 1900, year => $time[5] + 1900,
month => $time[4] + 1, month => $time[4] + 1,
day => $time[3], day => $time[3],
...@@ -452,12 +452,21 @@ sub datetime_from { ...@@ -452,12 +452,21 @@ sub datetime_from {
minute => $time[1], minute => $time[1],
# DateTime doesn't like fractional seconds. # DateTime doesn't like fractional seconds.
# Also, sometimes seconds are undef. # 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 # If a timezone was specified, use it. Otherwise, use the
# local timezone. # local timezone.
time_zone => Bugzilla->local_timezone->offset_as_string($time[6]) time_zone => Bugzilla->local_timezone->offset_as_string($time[6])
|| Bugzilla->local_timezone, || 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, # Now display the date using the given timezone,
# or the user's timezone if none is given. # or the user's timezone if none is given.
......
...@@ -43,6 +43,8 @@ sub datetime_format_inbound { ...@@ -43,6 +43,8 @@ sub datetime_format_inbound {
sub datetime_format_outbound { sub datetime_format_outbound {
my ($self, $date) = @_; my ($self, $date) = @_;
return undef if (!defined $date or $date eq '');
my $time = $date; my $time = $date;
if (blessed($date)) { if (blessed($date)) {
# We expect this to mean we were sent a datetime object # We expect this to mean we were sent a datetime object
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment