Skip to content

Remove moment from the public API of the date module#11418

Merged
youknowriad merged 2 commits intomasterfrom
remove/moment-from-public-api-data
Nov 6, 2018
Merged

Remove moment from the public API of the date module#11418
youknowriad merged 2 commits intomasterfrom
remove/moment-from-public-api-data

Conversation

@youknowriad
Copy link
Copy Markdown
Contributor

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

  • Make sure scheduling still works as expected (especially if the WP timezone is different from the browser's timezone).

@youknowriad youknowriad added the [Package] Date /packages/date label Nov 2, 2018
@youknowriad youknowriad added this to the 4.3 milestone Nov 2, 2018
@youknowriad youknowriad self-assigned this Nov 2, 2018
@youknowriad youknowriad requested a review from a team November 2, 2018 16:00
Copy link
Copy Markdown
Member

@tofumatt tofumatt left a 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.


describe( 'isEditedPostBeingScheduled', () => {
it( 'should return true for posts with a future date', () => {
const time = Date.now() + ( 1000 * 3600 * 24 * 7 ); // sdays in the future
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

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 :)

aduth
aduth previously requested changes Nov 2, 2018

return [ 'publish', 'private' ].indexOf( post.status ) !== -1 ||
( post.status === 'future' && moment( post.date ).isBefore( moment() ) );
( post.status === 'future' && ! isInTheFuture( post.date, 1 ) );
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

@aduth aduth Nov 2, 2018

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 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Date /packages/date

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants