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 the isBeingScheduled Selector. #11572

Merged
merged 4 commits into from
Nov 7, 2018
Merged

Conversation

youknowriad
Copy link
Contributor

closes #11554

Dealing with timezones in JavaScript while the timezone is defined in the server is hard in WordPress. Hopefully, I added some tests to the date module to avoid breakage.

This fixes two issues:

  • Doing new Date( wpDateString ) is wrong because it will read the date as if it was in the browser's timezone which is wrong. I added a getDate function to the date module to apply the WP timezone instead.

  • A small bug introduced in Remove moment from the public API of the date module #11418 (where instead of removing a minute offset, we were adding a minute)

@youknowriad youknowriad added [Type] Bug An existing feature does not function as intended [Package] Date /packages/date labels Nov 7, 2018
@youknowriad youknowriad self-assigned this Nov 7, 2018
@youknowriad youknowriad requested review from tofumatt and a team November 7, 2018 10:11
@youknowriad youknowriad added this to the 4.3 milestone Nov 7, 2018
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; I think it's worth tweaking the comments a bit as mentioned but it fixes the bug for me! 👍

@@ -406,4 +406,20 @@ export function isInTheFuture( dateValue ) {
return momentObject.isAfter( now );
}

/**
* Given a string containing a date object formatted using the WP timezone
Copy link
Member

Choose a reason for hiding this comment

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

This documentation is worded a bit oddly; I'll attempt a little rewrite 😄

packages/date/src/test/index.js Outdated Show resolved Hide resolved
Co-Authored-By: youknowriad <[email protected]>
@youknowriad youknowriad force-pushed the fix/is-in-the-future-function branch from 4648009 to 4dcc13f Compare November 7, 2018 14:04
@youknowriad youknowriad merged commit 1ac70e1 into master Nov 7, 2018
@youknowriad youknowriad deleted the fix/is-in-the-future-function branch November 7, 2018 15:55
daniloercoli added a commit that referenced this pull request Nov 7, 2018
…rnmobile/fix-merge-content-not-refreshed-UI

* 'master' of https://github.com/WordPress/gutenberg:
  Fix the isBeingScheduled Selector.  (#11572)
  Slot/Fill pattern with Toolbar #199 (#11115)
  Add mechanism to avoid forced child selection on blocks with templates. (#10696)
  Allow a block to disable being converted into a reusable block; Fix: Column block (#11550)
@@ -395,7 +395,7 @@ export function dateI18n( dateFormat, dateValue = new Date(), gmt = false ) {
/**
* Check whether a date is considered in the future according to the WordPress settings.
*
* @param {(Date|string)} dateValue Date object or string.
* @param {string} dateValue Date String or Date object in the Defined WP Timezone.
Copy link
Member

Choose a reason for hiding this comment

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

So is it a string or an object? The current documentation here sends mixed messaging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Date /packages/date [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Post set to publish immediately shows a "Schedule" button instead of "Publish" button
3 participants