Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dateFormat "could not be converted to a valid timestamp" #35

Open
teaqu opened this issue Aug 14, 2020 · 1 comment
Open

dateFormat "could not be converted to a valid timestamp" #35

teaqu opened this issue Aug 14, 2020 · 1 comment
Labels

Comments

@teaqu
Copy link

teaqu commented Aug 14, 2020

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 teaqu changed the title dateFormat Issue dateFormat "could not be converted to a valid timestamp" Aug 14, 2020
@airmoi
Copy link
Owner

airmoi commented Sep 10, 2020

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 airmoi added the bug label Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants