Handle the case when the defaultValue is in mysql format for the Thingy, but we have to save in epoch. Fix a timezone offset issue. Fixes bug #12197

This commit is contained in:
Colin Kuskie 2011-07-18 20:32:02 -07:00
parent 39f026f866
commit 2ce2d7611a
3 changed files with 10 additions and 6 deletions

View file

@ -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

View file

@ -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 );

View file

@ -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';