-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Remove moment from the public API of the date module #11418
Conversation
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 good to me; mostly curious about "sdays" and have some minor tweak suggestions.
@@ -1497,10 +1496,12 @@ describe( 'selectors', () => { | |||
|
|||
describe( 'isEditedPostBeingScheduled', () => { | |||
it( 'should return true for posts with a future date', () => { | |||
const time = Date.now() + ( 1000 * 3600 * 24 * 7 ); // sdays in the future |
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.
What does "sdays" mean here?
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.
It means "7 days", it's a new language invented by my broken keyboard :)
@@ -300,7 +300,7 @@ export function isCurrentPostPublished( state ) { | |||
const post = getCurrentPost( state ); | |||
|
|||
return [ 'publish', 'private' ].indexOf( post.status ) !== -1 || | |||
( post.status === 'future' && moment( post.date ).isBefore( moment() ) ); | |||
( post.status === 'future' && ! isInTheFuture( post.date, 1 ) ); |
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.
Will a future maintainer understand what the second argument it is by glancing at it? It confuses me just now looking at 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.
Can we prepare this ahead of time? If it's an ISO-8601 string, could we just do new Date( Number( new Date( post.date ) ) + MINUTE_IN_MS )
8e9b7f3
to
03102d4
Compare
I'm doing so by adding a new function in the data module
isInTheFuture
to check whether a given WP date is considered in the future or not.Testing instructions