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

fix: Time::setTimestamp()'s different behavior than DateTime #9106

Merged
merged 4 commits into from
Aug 21, 2024

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Aug 6, 2024

Description
Follow-up #9105

  • fix Time::setTimestamp() behavior.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added bug Verified issues on the current code behavior or pull requests that will fix them breaking change Pull requests that may break existing functionalities 4.6 labels Aug 6, 2024
@kenjis kenjis changed the title fix!: Time::setTimestamp()'s different behavior than DateTime fix: Time::setTimestamp()'s different behavior than DateTime Aug 6, 2024
Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a changelog entry for this.

@kenjis kenjis force-pushed the fix-Time-setTimestamp branch from 1355800 to f2fb30c Compare August 20, 2024 06:45
@kenjis kenjis force-pushed the fix-Time-setTimestamp branch from f2fb30c to 9395543 Compare August 20, 2024 06:56
@kenjis
Copy link
Member Author

kenjis commented Aug 20, 2024

Added docs.

*
* @return static
*
* @throws Exception
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the docs for the setTimestamp method, it mentions that an Exception may be thrown, but the method itself does not handle any exceptions directly. Should an appropriate exception be thrown?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parent class (DateTimeImmutable) throws Exception.

CI is kind of thin wrapper for PHP, so I don't think it's necessary to change PHP's behavior unless there is a need to do so.


echo $time2->format('Y-m-d H:i:s P');
// Before: 2024-08-20 00:00:00 -05:00
// After: 2024-08-19 19:00:00 -05:00
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// After: 2024-08-19 19:00:00 -05:00
// After: 2024-08-19 19:00:00 -05:00

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The : symbols have been aligned for easier reading.


echo $time2->format('Y-m-d H:i:s P');
// Before: 2024-08-20 00:00:00 -05:00
// After: 2024-08-20 00:00:00 -05:00
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// After: 2024-08-20 00:00:00 -05:00
// After: 2024-08-20 00:00:00 -05:00

Time::setTimestamp() Behavior Fix
=================================

In previous versions, if you call ``Time::setTimestamp()`` on a Time instance with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better to use this?

Suggested change
In previous versions, if you call ``Time::setTimestamp()`` on a Time instance with
In previous versions, if you call :php:meth:`Time::setTimestamp()` on a Time instance with

Copy link
Member Author

@kenjis kenjis Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:php:meth: makes a link to the class reference.
But there is no class reference for Time::setTimestamp() method.

Class reference is something like the following:
https://codeigniter4.github.io/CodeIgniter4/outgoing/view_renderer.html#namespace-CodeIgniter\View

Copy link
Contributor

@datamweb datamweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@kenjis kenjis merged commit 7e58971 into codeigniter4:4.6 Aug 21, 2024
42 checks passed
@kenjis kenjis deleted the fix-Time-setTimestamp branch August 21, 2024 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Pull requests that may break existing functionalities bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants