Don't consider a time zone when given a mysql style date, versus an epochal date. Fixes bug #11946.
This commit is contained in:
parent
5c4066413c
commit
76f32f3b6d
3 changed files with 13 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
7.10.5
|
||||
- fixed #11950: Username set to 0 when edit user
|
||||
- fixed #11946: Double time zone correction when addding an event
|
||||
|
||||
7.10.4
|
||||
- Added WebGUI::Fork api
|
||||
|
|
|
|||
|
|
@ -245,7 +245,10 @@ sub toHtml {
|
|||
my $originalValue = $self->getOriginalValue;
|
||||
my $dt = eval { WebGUI::DateTime->new($session, $originalValue); };
|
||||
$dt = WebGUI::DateTime->new($session,0) if ! (blessed $dt && $dt->isa('DateTime')); ##Parsing error
|
||||
$dt->set_time_zone($session->datetime->getTimeZone);
|
||||
if ($originalValue =~ $isaEpoch) {
|
||||
##Epoch date, correct for time zone;
|
||||
$dt->set_time_zone($session->datetime->getTimeZone);
|
||||
}
|
||||
$value = $dt->toMysqlDate;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ my $testBlock = [
|
|||
|
||||
my $formType = 'date';
|
||||
|
||||
my $numTests = 27 + scalar @{ $testBlock } ;
|
||||
my $numTests = 28 + scalar @{ $testBlock } ;
|
||||
|
||||
|
||||
plan tests => $numTests;
|
||||
|
|
@ -145,7 +145,7 @@ is(
|
|||
$date2 = WebGUI::Form::Date->new($session, {defaultValue => '2008-008-001'});
|
||||
is(
|
||||
getValueFromForm($session, $date2->toHtml),
|
||||
'1969-12-31',
|
||||
'1970-01-01',
|
||||
"toHtml: defaultValue in bad mysql format returns date from epoch 0"
|
||||
);
|
||||
|
||||
|
|
@ -172,6 +172,12 @@ my $epochal_value = $date_form->getValue;
|
|||
$date_form->set(value => $epochal_value);
|
||||
my $mysql_date = getValueFromForm($session, $date_form->toHtml);
|
||||
is $mysql_date, '2001-08-16', 'Form data processed and rendered round trip';
|
||||
$session->request->setup_body({});
|
||||
|
||||
$session->user({userId => 1, });
|
||||
my $day_form = WebGUI::Form::Date->new($session, { name => 'day_date', value=>'2001-08-16'});
|
||||
my $day16 = getValueFromForm($session, $day_form->toHtml);
|
||||
is $day16, '2001-08-16', 'day set correctly in form';
|
||||
|
||||
sub getValueFromForm {
|
||||
my ($session, $textForm) = @_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue