Skip to content

Enable Scheduling - Add TZ to page StartDate and EndDate#3919

Merged
mitchelsellers merged 1 commit intodnnsoftware:developfrom
daguiler:bugfix/DNN-33895
Jul 18, 2020
Merged

Enable Scheduling - Add TZ to page StartDate and EndDate#3919
mitchelsellers merged 1 commit intodnnsoftware:developfrom
daguiler:bugfix/DNN-33895

Conversation

@daguiler
Copy link
Copy Markdown
Contributor

Fixes #3918

Summary

This is both a back-end issue and a front-end issue.

Initially, when start/end datetime is null, and the user picks a datetime in the date picker, the front-end sends the datetimes correctly as UTC, and the back-end API saves the datetimes correctly in the database as UTC.

Later, during browser refresh, the GetPageDetails API is called, which fails to specify the DateTimeKind as UTC when filling the DTO from the database, and therefore the datetimes are serialized back as local datetimes, which produces the offset in the front-end.

At this point, if the user changes the datetime back to the original value, this time the date picker returns a String instead of a javascript Date object, and the TZ info is lost there, and the API then receives a local datetime. This sort of fixes the problem thereafter, but out of pure luck I would say.

This pull request basically adds the lost TZ both in the back-end (by specifying the DateTimeKind) and the front-end (using Date objects with the view model instead of strings).

return {
...pageResult.page,
schedulingEnabled: pageResult.page.startDate || pageResult.page.endDate,
schedulingEnabled: pageResult.page.startDate !== null || pageResult.page.endDate !== null,
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.

This change was not strictly necessary, but React was complaining that schedulingEnabled was being assigned a string instead of a boolean value.

@mitchelsellers mitchelsellers merged commit 3e9d129 into dnnsoftware:develop Jul 18, 2020
@daguiler daguiler deleted the bugfix/DNN-33895 branch July 18, 2020 04:09
@LeoZandvliet LeoZandvliet mentioned this pull request Sep 8, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Page schedule Start and End dates change after saving

3 participants