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

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