-
Notifications
You must be signed in to change notification settings - Fork 29
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
IBX-300: Added timezone offset to timestamp #181
Conversation
I've noticed that public static function fromTimestamp($timestamp)
{
try {
- return new static(new DateTime("@{$timestamp}"));
+ $datetime = new DateTime();
+ $datetime->setTimestamp($timestamp);
+
+ return new static($datetime);
} catch (Exception $e) {
throw new InvalidArgumentValue('$timestamp', $timestamp, __CLASS__, $e);
}
} Reason for this is that This might be the reason why those datetimes differ in the first place. Adding default offset would cause that an actually invalid timestamp would be stored (!). See: https://www.php.net/manual/en/datetime.construct.php#refsect1-datetime.construct-parameters
EDIT: I'm rather sure that this is the root of the issue you're fixing. As I said, you're storing offset info into timestamp (timestamps should not change depending on timezone). When creating |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the issue raised in the comment.
The proposed change actually works as you describe, but then there is a problem on the front side, so I need to verify the JS files that are responsible for it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we're missing test coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @alongosz do you think we need some more tests for this?
One thing to note: do we need to migrate anyone? Can any customer have timestamps stored with an offset? |
I think no, there shouldn't be any incorrect data saved anywhere, because when creating this item we changed the timestamp (add offset timezone) via JS now we do it in PHP |
eZ/Publish/API/Repository/Tests/FieldType/DateIntegrationTest.php
Outdated
Show resolved
Hide resolved
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Similar issues exist in |
merge up - done |
v3.2
Related PR: ezsystems/ezplatform-admin-ui#1752
Checklist:
$ composer fix-cs
).@ezsystems/php-dev-team
).