A user reported in HS that cannot set the publish date for a new post in the past.

On already published posts the user can set a "back-date" without issues.
Came to report this myself. Had to drop to a web UI to complete my task.
@daniloercoli I was investigating the code and there seems to be some intentional logic behind this functionality. If you create a new post and you set a post date, you can set it in past. If you create a draft, you cannot do that. There is an option that allows the publishImmediatelyOption to be available with this comment:
// Only drafts should have the option to publish immediately to avoid user confusion
Then there is some logic that sets the min start date when the publishImmediatelyOption is true:
if (canPublishImmediately) {
// We shouldn't let the user pick a past date since we'll just override it to Immediately if they do
// We can't set the min date to now, so we need to subtract some amount of time
datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
}
Edit: I tried removing this logic and the thing is that updating the post date doesn't automatically publish the draft and gets overriden by the Now field.
Edit2: Even though setting date to future is enabled, it doesn't really do anything for drafts. The date still gets set to Now.
Edit: I tried removing this logic and the thing is that updating the post date doesn't automatically publish the draft and gets overriden by the Now field.
Edit2: Even though setting date to future is enabled, it doesn't really do anything for drafts. The date still gets set to Now.
It seems a bug that future/past date is not working as expected.
I both tried on Calypso UI, and wp-admin on a self-hosted site, and was able to back date a draft.
The change in https://github.com/wordpress-mobile/WordPress-Android/pull/9322 makes this issue more severe, since new posts have a draft status (so there's no way to backdate the post without knowing that you have to switch to publish status first). cc @mzorz
Ok been investigating this - I'll add the information here for completeness.
It seems this particular condition has been introduced by design in https://github.com/wordpress-mobile/WordPress-Android/commit/a1d0acdfaca46cbe5df802b948bbd3627b1786a3
The PR containing this commit has a good explanation on what has been decided: https://github.com/wordpress-mobile/WordPress-Android/pull/6122.
Copying it here for ease:
Our solution:
1. Always use & show the `date` property in "Publish Date" and let the user update it to whenever they want (including past dates)
2. If the post is a draft, let the user set a future date. If a future date is set, treat it like the option 1.
3. Don't let the user set a past date for a draft. Theoretically they can do so if they select the current date and a prior time, but this doesn't matter too much. The only reason we do this is to avoid confusing the user due to 4 & 5.
4. If the post is a draft and if the `date` field is now or in the past, show "Immediately" instead
5. If 4 is true, just before a post is published, update the date field to current time which should be consistent with Calypso and wp-admin.
Opened a PR to fix this https://github.com/wordpress-mobile/WordPress-Android/pull/9466
Closing via #9466