FileMaker icon indicating copy to clipboard operation
FileMaker copied to clipboard

dateFormat "could not be converted to a valid timestamp"

Open teaqu opened this issue 5 years ago • 1 comments

Hello,

If you set a custom dateFormat the following code will throw a "could not be converted to a valid timestamp" exception.

$record = $this->fileMaker->createRecord('layout', $data);
$record->commit();

The reason seems to be that DateFormat::convert() is run twice. First in Record::setField() and then later in Add::setField(). The problem with this is that DateFormat will try to convert an already converted value.

This issue can be avoided if I run:

$this->fileMaker->newAddCommand('layout', $data)->execute();

as then setField() is only run in Add.

One way to stop this issue could be to avoid conversions on dates that are already in the m/d/Y format. What do you think?

teaqu avatar Aug 14 '20 22:08 teaqu

Hi,

Thanks for reporting this. I think the issue is at Record::setField level, which should not convert date/timestamp as your record would then return "default" date formatted values instead of the one you defined in properties which leads to inconsistent behaviors.

Will investigate deeper and see if I can fix this in a smart way without breaking any existing deployment

airmoi avatar Sep 10 '20 16:09 airmoi