Skip to content

Update the existing date/time property editor to provide a kind of unspecified #19727

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

Conversation

lauraneto
Copy link
Contributor

When requesting a value from the existing date/time property editor, the returned DateTime will now have Kind set to Unspecified instead of Utc.

Testing

  1. Create a document type with template, allowed at root, with a property using a Umbraco.DateTime property editor.
  2. Create and publish a node using the created document type and set a value in the date field.

Code

  1. Adjust the document type template to:
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@{
    Layout = null;
    var date = Model.Value<DateTime>("date");
}

@date (@date.Kind)
  1. Access the url of the node

Before the changes:1/1/2026 6:02:00 AM (Utc)
After the changes: 1/1/2026 6:02:00 AM (Unspecified)

Delivery API

  1. Enable the Delivery API.
  2. Request the content node from the delivery API.
    Example: https://localhost:44331/umbraco/delivery/api/v2/content/item/%2F?fields=properties%5B%24all%5D

Before the changes:2026-01-01T06:02:00Z
After the changes: 2026-01-01T06:02:00

@lauraneto lauraneto marked this pull request as ready for review July 21, 2025 08:09
@Copilot Copilot AI review requested due to automatic review settings July 21, 2025 08:09
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the DateTime property editor value converter to return DateTime values with DateTimeKind.Unspecified instead of DateTimeKind.Utc. This change affects how DateTime values are interpreted both in Razor templates and the Delivery API, removing the UTC timezone assumption from returned values.

  • Modified the ParseDateTimeValue method to explicitly set DateTimeKind.Unspecified on all returned DateTime values
  • Refactored the method logic to use pattern matching for cleaner conditional flow
  • Maintained the same fallback behavior of returning DateTime.MinValue for invalid inputs

@lauraneto lauraneto marked this pull request as draft July 21, 2025 08:31
@lauraneto lauraneto marked this pull request as ready for review July 21, 2025 12:08
Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

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

Code all looks good and can see from the unit tests and checks on template rendering and delivery API that the output is as expected.

@AndyButland AndyButland merged commit 3fcc091 into v17/dev Jul 22, 2025
24 checks passed
@AndyButland AndyButland deleted the v17/improvement/update-the-existing-datetime-property-editor-to-provide-a-Kind-of-Unspecified branch July 22, 2025 09:55
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.

2 participants