diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index ae9a68ecc..4407a3420 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -17,6 +17,7 @@ - fixed #12135: Geo::Coder::Googlev3 needs common sense - fixed #12183: Posts do not disqualify themselves when purged - fixed #12189: installClass ignores preload.custom + - fixed #12197: Default date Thingy disables date 7.10.19 - fixed #12169: extras uploads symlink export diff --git a/lib/WebGUI/Asset/Wobject/Thingy.pm b/lib/WebGUI/Asset/Wobject/Thingy.pm index d4c26dac0..d5e502c97 100644 --- a/lib/WebGUI/Asset/Wobject/Thingy.pm +++ b/lib/WebGUI/Asset/Wobject/Thingy.pm @@ -656,6 +656,10 @@ sub editThingDataSave { if ($self->field_isa($fieldType, 'WebGUI::Form::File')) { $field->{ defaultValue } = $thingData{ "field_" . $field->{ fieldId } }; } + elsif ($fieldType eq 'Date' or $fieldType eq 'DateTime') { ##Must be in epoch format to be stored in the db. + my $wdt = WebGUI::DateTime->new($session, $field->{defaultValue})->cloneToUserTimeZone; + $field->{defaultValue} = $wdt->epoch; + } $fieldValue = $thingData->{$fieldName} || $session->form->process($fieldName,$fieldType,$field->{defaultValue},$field); } if ($field->{status} eq "required" && ($fieldValue =~ /^\s$/x || $fieldValue eq "" || !(defined $fieldValue))) { @@ -1047,12 +1051,12 @@ sub getFieldValue { my $fieldType = lc $field->{fieldType}; if ($fieldType eq "date"){ - my $dt = WebGUI::DateTime->new($session, $value); - $processedValue = $dt->webguiDate($dateFormat); + my $wdt = WebGUI::DateTime->new($session, $value); + $processedValue = $wdt->cloneToUserTimeZone->webguiDate($dateFormat); } elsif ($fieldType eq "datetime"){ - my $dt = WebGUI::DateTime->new($session, $value); - $processedValue = $dt->webguiDate($dateTimeFormat); + my $wdt = WebGUI::DateTime->new($session, $value); + $processedValue = $wdt->cloneToUserTimeZone->webguiDate($dateTimeFormat); } # TODO: The otherThing field type is probably also handled by getFormPlugin, so the elsif below can probably be # safely removed. However, this requires more testing than I can provide right now, so for now this stays the @@ -3083,7 +3087,6 @@ sub www_exportThing { ### Loop through the returned structure and put it through Text::CSV # Column heads - $self->session->log->warn("field labels: ". join ' ', @fieldLabels); my $csv_filename = 'export_'.$thingProperties->{label}.'.csv'; open my $CSV, '>', $tempStorage->getPath($csv_filename); print $CSV WebGUI::Text::joinCSV( @fieldLabels ); diff --git a/t/Asset/Wobject/Thingy/getFieldValue.t b/t/Asset/Wobject/Thingy/getFieldValue.t index e26b9ea82..c7ebbb214 100644 --- a/t/Asset/Wobject/Thingy/getFieldValue.t +++ b/t/Asset/Wobject/Thingy/getFieldValue.t @@ -81,4 +81,4 @@ my $field1 = $thingy->getFields($thingId)->hashRef; note 'getFieldValue'; is $thingy->getFieldValue(WebGUI::Test->webguiBirthday, $field1), '8/16/2001', 'with epoch as default'; -is $thingy->getFieldValue('2011-07-04', $field1), '7/4/2011', 'with mysql date as default'; +is $thingy->getFieldValue('2011-07-04', $field1), '7/3/2011', 'with mysql date as default';