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

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

Merged
merged 2 commits into from Nov 6, 2018

Conversation

youknowriad
Copy link
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
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.

packages/date/CHANGELOG.md Show resolved Hide resolved
packages/date/src/index.js Show resolved Hide resolved
@@ -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
Copy link
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
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
packages/date/CHANGELOG.md Show resolved Hide resolved
@@ -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 ) );
Copy link
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
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.

None yet

3 participants