-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Persist and expose Umbraco system dates as UTC #19705
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
Open
AndyButland
wants to merge
16
commits into
v17/feature/utc-system-dates
Choose a base branch
from
v17/feature/utc-system-dates-database-dates-persist-utc
base: v17/feature/utc-system-dates
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Persist and expose Umbraco system dates as UTC #19705
AndyButland
wants to merge
16
commits into
v17/feature/utc-system-dates
from
v17/feature/utc-system-dates-database-dates-persist-utc
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…t when not specified is true).
… date constraints.
…or and outputting in delivery API.
…em-dates-database-dates-persist-utc
…ocument history, so we can control the UTC setting on the retrieved persisted dates.
…lished for variant content.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
This is a first PR toward making Umbraco's handling of system dates more consistent by using UTC throughout. It's targeted at
v17/feature/utc-system-dates
, a feature branch taken fromv17/dev
, with the idea that we create a few, smaller PRs into the feature branch and then finally merge it intov17/dev
when we are happy with it.When merged, this PR will make the following changes:
SpecifyKind
to ensure we have local server time when we have otherwise retrieved UTC. Again UTC is what we want now.DateTime.Now
to useDateTime.UtcNow
.ALTER TABLE
support, the existing constraints aren't correct, and we don't rely on them in application code).Kind
, and it's the same when retrieving from the hybrid cache. Used this in factory methods to ensure entities and published content are built with datetimes as UTC.Kind
we ensure anywhere downstream gets this too.Note that the following is not part of this PR, so isn't expected to work correctly:
Note also that I've removed some tests from files that were completely commented out (since Umbraco 15 I believe, with the introduction of the Hybrid cache). Most of them used dates and would get out of sync if we kept them, so I thought it was better now to remove.
Testing
Date Persistence
Easiest for testing to start with is to start off with a clean database and install Umbraco. Using database queries like the following you can verify that the default data installed uses UTC:
Then make some updates that will affect dates, e.g.:
Date Presentation
Management API
Verify management API endpoints are returning the expected dates, e.g.:
Should return datetime responses like:
Backoffice
Verify that the backoffice is displaying the dates in the user's local time. I haven't touched this, but seems they "just work" due to the use of localized dates, so long as we are providing a date with timezone information from the management API, which we are.
Delivery API
Verify delivery API endpoints are returning the expected dates, e.g.:
Should return datetime responses like:
Templates
Verify that Razor rendering makes available the system dates as UTC, e.g. with:
Migration of Database DateTime Default Constraints
For this one take an Umbraco database for Umbraco 16, and verify for example that the
umbracoNode.createDate
table has a default value ofgetdate()
.Then connect the database to the code in this PR and restart so the migration runs.
You should find that the default is now
getutcdate()
.