Allow users to enter 24:00:00 by hand, and have the Event handle it correctly. Fixes bug #11788

This commit is contained in:
Colin Kuskie 2010-09-13 11:04:03 -07:00
parent 3c15058bc6
commit 1d99ee451e
3 changed files with 47 additions and 5 deletions

View file

@ -3,6 +3,7 @@
- fixed #11854: CS doesn't return Not Found page
- fixed #11746: Thingy import CSV only supports one line ending
- fixed #11833: Recheck for losing Product Images
- fixed #11788: Calendar - Can't enter Midnight - Broke page layout
7.10.0
- fixed #11812: Checking www_ajaxSave's response in the cart js, urlencoding post parameters

View file

@ -1711,8 +1711,37 @@ Wrap update so that isHidden is always set to be a 1.
=cut
sub update {
my $self = shift;
my $self = shift;
my $properties = shift;
my $session = $self->session;
if (my $startTime = $properties->{startTime}) {
my ($startHour, $startMinute, $startSecond) = $startTime =~ /^ (\d+) : (\d+) (?: :(\d+)) /x;
if ($startHour > 23) {
$startHour = 0;
my $startDate = exists $properties->{startDate} ? $properties->{startDate} : $self->get('startDate');
$session->log->warn('startDate: '. $startDate);
my $startDt = WebGUI::DateTime->new($session, $startDate);
$startDt->add(days => 1);
$properties->{startDate} = $startDt->toMysqlDate;
$session->log->warn('startDate: '. $properties->{startDate});
$startSecond = '00' if ! $startSecond;
$properties->{startTime} = sprintf '%02d:%02d:%02d', $startHour, $startMinute, $startSecond;
}
}
if (my $endTime = $properties->{endTime}) {
my ($endHour, $endMinute, $endSecond) = $endTime =~ /^ (\d+) : (\d+) (?: :(\d+)) /x;
if ($endHour > 23) {
$endHour = 0;
my $endDate = exists $properties->{endDate} ? $properties->{endDate} : $self->get('endDate');
$session->log->warn('endDate: '. $endDate);
my $endDt = WebGUI::DateTime->new($session, $endDate);
$endDt->add(days => 1);
$properties->{endDate} = $endDt->toMysqlDate;
$session->log->warn('endDate: '. $properties->{endDate});
$endSecond = '00' if ! $endSecond;
$properties->{endTime} = sprintf '%02d:%02d:%02d', $endHour, $endMinute, $endSecond;
}
}
return $self->SUPER::update({%$properties, isHidden => 1});
}

View file

@ -19,7 +19,7 @@ use WebGUI::Asset::Event;
use Test::More; # increment this value for each test you create
use Test::Deep;
plan tests => 18;
plan tests => 22;
my $session = WebGUI::Test->session;
@ -122,12 +122,24 @@ my $eventStorage = WebGUI::Storage->create($session);
WebGUI::Test->addToCleanup($eventStorage);
$properties3->{storageId} = $eventStorage->getId;
my $event6 = $cal->addChild($properties3, $properties3->{id});
sleep 2;
my $event6 = $cal->addChild($properties3, $properties3->{id}, time()-5);
my $event6a = $event6->addRevision({ title => 'Event with storage', }, undef, { skipAutoCommitWorkflows => 1, });
ok($session->id->valid($event6a->get('storageId')), 'addRevision gives the new revision a valid storageId');
isnt($event6a->get('storageId'), $event6->get('storageId'), '... and it is different from the previous revision');
my $versionTag2 = WebGUI::VersionTag->getWorking($session);
WebGUI::Test->addToCleanup($versionTag2);
my $event7 = $cal->addChild({
className => 'WebGUI::Asset::Event',
startDate => '2000-08-31',
startTime => '24:00:00',
endDate => '2000-09-01',
endTime => '24:00:00',
});
is ($event7->get('startTime'), '00:00:00', 'startTime set to 00:00:00 if the hour is more than 23');
is ($event7->get('startDate'), '2000-09-01', 'startDate bumped by 1 day');
is ($event7->get('endTime'), '00:00:00', 'endTime set to 00:00:00 if the hour is more than 23');
is ($event7->get('endDate'), '2000-09-02', 'endDate bumped by 1 day');