Added a test to see if clone would duplicate the session. It does.

Subclassed DateTime's from_object method, which was secretely deleting
the internal session variable.  There is probably a more robust way to
do this, such as by "...implementing the utc_rd_values() method as the
from_object docs suggest.
Finished fixing the bug with time zone errors in editing an event.
This commit is contained in:
Colin Kuskie 2007-01-19 06:25:43 +00:00
parent 17fac4a7cb
commit 2180b9bf91
4 changed files with 27 additions and 11 deletions

View file

@ -2,6 +2,7 @@
- fix: Checkbox is no longer available when creating custom profile fields
- fix: profile fields do not ever set the default value
- fix: CS email message shows up as an attachment
- fix: Calendar: start/end date time off in edit interface (perlDreamer Consulting, LLC)
7.3.5

View file

@ -289,13 +289,13 @@ sub getDateTimeStart
if ($time)
{
my $dt = new WebGUI::DateTime($self->session, $date." ".$time);
my $dt = WebGUI::DateTime->new($self->session, $date." ".$time);
$dt->set_time_zone($tz);
return $dt;
}
else
{
my $dt = new WebGUI::DateTime($self->session, $date." 00:00:00");
my $dt = WebGUI::DateTime->new($self->session, $date." 00:00:00");
return $dt;
}
}
@ -333,13 +333,13 @@ sub getDateTimeEnd
if ($time)
{
my $dt = new WebGUI::DateTime($self->session, $date." ".$time);
my $dt = WebGUI::DateTime->new($self->session, $date." ".$time);
$dt->set_time_zone($tz);
return $dt;
}
else
{
my $dt = new WebGUI::DateTime($self->session, $date." 23:59:59");
my $dt = WebGUI::DateTime->new($self->session, $date." 23:59:59");
return $dt;
}
}
@ -1767,22 +1767,19 @@ sub www_edit
# end date
$default_start->add(hours => 1);
#my ($endDate,$endTime) = split / /, $self->getDateTimeEnd->toMysql
my ($endDate,$endTime) = split / /, $self->getDateTimeEnd->toUserTimeZone
unless $func eq "add" || $self->get("assetId") eq "new";
$var->{"formEndDate"} = WebGUI::Form::date($session,
{
name => "endDate",
value => $form->process("endDate") || $endDate,
#defaultValue => $default_start->toMysqlDate,
defaultValue => $default_start->toUserTimeZoneDate,
});
$var->{"formEndTime"} = WebGUI::Form::timeField($session,
{
name => "endTime",
value => $form->process("endTime") || $endTime,
defaultValue => $default_start->toMysqlTime,
#defaultValue => $default_start->toUserTimeZoneTime,
defaultValue => $default_start->toUserTimeZoneTime,
});
# time

View file

@ -205,6 +205,23 @@ sub cloneToUserTimeZone {
#######################################################################
=head2 from_object
Handle copying all WebGUI::DateTime specific data. This is a class method.
=cut
sub from_object {
my $class = shift;
my %args = @_;
my $session = $args{object}->session;
my $copy = $class->SUPER::from_object(@_);
$copy->session($session);
return $copy;
}
#######################################################################
=head2 toDatabase
Returns a MySQL Date/Time string in the UTC time zone
@ -398,7 +415,7 @@ This is going to have to be changed eventually so you don't have to set the sess
=cut
sub session {
my $self = shift;
my $self = shift;
my $session = shift;
if($session) {

View file

@ -23,7 +23,7 @@ my $session = WebGUI::Test->session;
# put your tests here
my $numTests = 1 + 12;
my $numTests = 1 + 13;
plan tests => $numTests;
my $loaded = use_ok("WebGUI::DateTime");
@ -46,7 +46,8 @@ is($dt->toDatabaseTime, "21:12:45", "toDatabaseTime returns the ident
$session->user({user => $timeZoneUser});
my $copiedDt = $dt->cloneToUserTimeZone;
isa_ok($copiedDt, "WebGUI::DateTime", "cloneToUserTimeZone");
isa_ok($copiedDt, "WebGUI::DateTime", "cloneToUserTimeZone");
isa_ok($copiedDt->session, "WebGUI::Session", "cloneToUserTimeZone also copies over the session object");
is($copiedDt->time_zone()->name, "America/Hermosillo", "cloned object has correct time zone");
is($dt->time_zone()->name, "UTC", "original object is still UTC");