Repository navigation
Fix: DateTimePicker passes current seconds as the selected seconds value - #15495
Conversation
|
This PR needs to be rebased with |
e2a710f to
d1b1f66
Compare
|
Hi @gziolo this PR was rebased. |
|
This is great! Thanks for fixing @jorgefilipecosta! |
|
Any update on this? |
Could you elaborate on this? What causes cron to miss the posts? |
I explained it here - #13898 (comment) Use case: I setup wordpress to use system cron (setup a cronjob calling the wp-cron every minute for example). After setting up the cronjob I plan a post for the next week on 20:00. The time in database stored is 20:00:43 (43 in this case is seconds, fully random, but in fact this are my browser seconds). |
aduth
left a comment
There was a problem hiding this comment.
Looks good. A nice refactor of some duplicate logic too 👍
| } | ||
| } | ||
|
|
||
| changeDate( newDate ) { |
There was a problem hiding this comment.
Might be nice for some docs, even if there's plenty of prior art of no documentation in this component.
d1b1f66 to
c270593
Compare
c270593 to
62c0af3
Compare
Replaces `startOfMinute( inputToDate(...) )` with a small local helper that mutates the seconds/ms on the `UTCDateMini` directly. In `date-fns` v4, `startOfMinute` calls `toDate()`, which goes through `constructFrom()` and does `new input.constructor(value)`. With our `UTCDateMini` (extends `Date`) plus `timezone-mock` swapping the global `Date` in tests, that re-construction trips MockDate's "Unhandled type passed... object" assertion, breaking 50+ DateTimePicker/TimePicker tests. Setting seconds and milliseconds via the UTCDateMini's own setSeconds keeps the truncation in UTC (UTCDateMini's prototype shim reroutes setSeconds to setUTCSeconds), preserves the existing #15495 behaviour, and decouples this code path from `date-fns` — useful for future upgrades.
Replaces `startOfMinute( inputToDate(...) )` with a small local helper that mutates the seconds/ms on the `UTCDateMini` directly. In `date-fns` v4, `startOfMinute` calls `toDate()`, which goes through `constructFrom()` and does `new input.constructor(value)`. With our `UTCDateMini` (extends `Date`) plus `timezone-mock` swapping the global `Date` in tests, that re-construction trips MockDate's "Unhandled type passed... object" assertion, breaking 50+ DateTimePicker/TimePicker tests. Setting seconds and milliseconds via the UTCDateMini's own setSeconds keeps the truncation in UTC (UTCDateMini's prototype shim reroutes setSeconds to setUTCSeconds), preserves the existing #15495 behaviour, and decouples this code path from `date-fns` — useful for future upgrades.
Replaces `startOfMinute( inputToDate(...) )` with a small local helper that mutates the seconds/ms on the `UTCDateMini` directly. In `date-fns` v4, `startOfMinute` calls `toDate()`, which goes through `constructFrom()` and does `new input.constructor(value)`. With our `UTCDateMini` (extends `Date`) plus `timezone-mock` swapping the global `Date` in tests, that re-construction trips MockDate's "Unhandled type passed... object" assertion, breaking 50+ DateTimePicker/TimePicker tests. Setting seconds and milliseconds via the UTCDateMini's own setSeconds keeps the truncation in UTC (UTCDateMini's prototype shim reroutes setSeconds to setUTCSeconds), preserves the existing #15495 behaviour, and decouples this code path from `date-fns` — useful for future upgrades.
Closes: #13898
DateTimePicker does not allow users to pick a value for seconds, so when the user changes a time/date, it should look like a value of 0 was selected as the seconds value. Currently, the seconds of the current date are passed as the selected seconds, which may make it look like a "random" value was selected as the seconds value.
This causes a regression where WP_CRON missed some scheduled posts.
How has this been tested?
I created a new post.
I changed the date/time fields in the post scheduling dialog and I verified with redux dev tools that the editPost action contained a date whose seconds were equal to 0.