diff --git a/src/Umbraco.Cms.Api.Management/Factories/DocumentVersionPresentationFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/DocumentVersionPresentationFactory.cs
index 6166d38d2d..2c3b80fd3c 100644
--- a/src/Umbraco.Cms.Api.Management/Factories/DocumentVersionPresentationFactory.cs
+++ b/src/Umbraco.Cms.Api.Management/Factories/DocumentVersionPresentationFactory.cs
@@ -26,7 +26,7 @@ internal sealed class DocumentVersionPresentationFactory : IDocumentVersionPrese
new ReferenceByIdModel(_entityService.GetKey(contentVersion.ContentTypeId, UmbracoObjectTypes.DocumentType)
.Result),
new ReferenceByIdModel(await _userIdKeyResolver.GetAsync(contentVersion.UserId)),
- new DateTimeOffset(contentVersion.VersionDate),
+ new DateTimeOffset(contentVersion.VersionDate, TimeSpan.Zero), // todo align with datetime offset rework
contentVersion.CurrentPublishedVersion,
contentVersion.CurrentDraftVersion,
contentVersion.PreventCleanup);
diff --git a/src/Umbraco.Core/Models/ContentVersionMeta.cs b/src/Umbraco.Core/Models/ContentVersionMeta.cs
index b9b1be6080..cf95257716 100644
--- a/src/Umbraco.Core/Models/ContentVersionMeta.cs
+++ b/src/Umbraco.Core/Models/ContentVersionMeta.cs
@@ -37,7 +37,7 @@ public class ContentVersionMeta
public int UserId { get; }
- public DateTime VersionDate { get; private set; }
+ public DateTime VersionDate { get; }
public bool CurrentPublishedVersion { get; }
@@ -47,7 +47,5 @@ public class ContentVersionMeta
public string? Username { get; }
- public void SpecifyVersionDateKind(DateTimeKind kind) => VersionDate = DateTime.SpecifyKind(VersionDate, kind);
-
public override string ToString() => $"ContentVersionMeta(versionId: {VersionId}, versionDate: {VersionDate:s}";
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/AccessDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/AccessDto.cs
index 0821232826..c5bfbc8c01 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/AccessDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/AccessDto.cs
@@ -27,11 +27,11 @@ internal class AccessDto
[ForeignKey(typeof(NodeDto), Name = "FK_umbracoAccess_umbracoNode_id2")]
public int NoAccessNodeId { get; set; }
- [Column("createDate")]
+ [Column("createDate", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime CreateDate { get; set; }
- [Column("updateDate")]
+ [Column("updateDate", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime UpdateDate { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/AccessRuleDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/AccessRuleDto.cs
index 3aba928bda..ec843c1c54 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/AccessRuleDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/AccessRuleDto.cs
@@ -25,11 +25,11 @@ internal class AccessRuleDto
[Column("ruleType")]
public string? RuleType { get; set; }
- [Column("createDate")]
+ [Column("createDate", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime CreateDate { get; set; }
- [Column("updateDate")]
+ [Column("updateDate", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime UpdateDate { get; set; }
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/AuditEntryDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/AuditEntryDto.cs
index 38e63ffc20..c94a680a1f 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/AuditEntryDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/AuditEntryDto.cs
@@ -30,7 +30,7 @@ internal class AuditEntryDto
[Length(Constants.Audit.IpLength)]
public string? PerformingIp { get; set; }
- [Column("eventDateUtc")]
+ [Column("eventDateUtc", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime EventDateUtc { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ConsentDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ConsentDto.cs
index c6f9006b29..67db05a3cf 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ConsentDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ConsentDto.cs
@@ -29,7 +29,7 @@ public class ConsentDto
[Length(512)]
public string? Action { get; set; }
- [Column("createDate")]
+ [Column("createDate", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime CreateDate { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentScheduleDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentScheduleDto.cs
index ad4c03ac53..8194448ce4 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentScheduleDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentScheduleDto.cs
@@ -24,6 +24,7 @@ internal class ContentScheduleDto
[NullSetting(NullSetting = NullSettings.Null)] // can be invariant
public int? LanguageId { get; set; }
+ // NOTE: this date is explicitly stored and treated as UTC despite the lack of "Utc" postfix.
[Column("date")]
public DateTime Date { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCleanupPolicyDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCleanupPolicyDto.cs
index 4dd1a14fb5..cdc36ad077 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCleanupPolicyDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCleanupPolicyDto.cs
@@ -27,6 +27,6 @@ internal class ContentVersionCleanupPolicyDto
[NullSetting(NullSetting = NullSettings.Null)]
public int? KeepLatestVersionPerDayForDays { get; set; }
- [Column("updated")]
+ [Column("updated", ForceToUtc = false)]
public DateTime Updated { get; set; }
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCultureVariationDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCultureVariationDto.cs
index b7d675f9a8..d77872ae20 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCultureVariationDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCultureVariationDto.cs
@@ -33,7 +33,7 @@ internal class ContentVersionCultureVariationDto
[Column("name")]
public string? Name { get; set; }
- [Column("date")] // TODO: db rename to 'updateDate'
+ [Column("date", ForceToUtc = false)] // TODO: db rename to 'updateDate'
public DateTime UpdateDate { get; set; }
[Column("availableUserId")] // TODO: db rename to 'updateDate'
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionDto.cs
index 07fe6d9a84..e05bcf0d05 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionDto.cs
@@ -22,7 +22,7 @@ public class ContentVersionDto
[Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_NodeId", ForColumns = "nodeId,current", IncludeColumns = "id,versionDate,text,userId,preventCleanup")]
public int NodeId { get; set; }
- [Column("versionDate")] // TODO: db rename to 'updateDate'
+ [Column("versionDate", ForceToUtc = false)] // TODO: db rename to 'updateDate'
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime VersionDate { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/CreatedPackageSchemaDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/CreatedPackageSchemaDto.cs
index 060c9d5a23..07ac53d552 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/CreatedPackageSchemaDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/CreatedPackageSchemaDto.cs
@@ -27,7 +27,7 @@ public class CreatedPackageSchemaDto
[NullSetting(NullSetting = NullSettings.NotNull)]
public string Value { get; set; } = null!;
- [Column("updateDate")]
+ [Column("updateDate", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime UpdateDate { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/DocumentPublishedReadOnlyDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/DocumentPublishedReadOnlyDto.cs
index 2f0b2ed5f5..0087298645 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/DocumentPublishedReadOnlyDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/DocumentPublishedReadOnlyDto.cs
@@ -20,6 +20,6 @@ internal class DocumentPublishedReadOnlyDto
[Column("newest")]
public bool Newest { get; set; }
- [Column("updateDate")]
+ [Column("updateDate", ForceToUtc = false)]
public DateTime VersionDate { get; set; }
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ExternalLoginDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ExternalLoginDto.cs
index 05c94ed3db..a34c1100a2 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ExternalLoginDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ExternalLoginDto.cs
@@ -42,7 +42,7 @@ internal class ExternalLoginDto
[Index(IndexTypes.NonClustered, ForColumns = "loginProvider,providerKey", Name = "IX_" + TableName + "_ProviderKey")]
public string ProviderKey { get; set; } = null!;
- [Column("createDate")]
+ [Column("createDate", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime CreateDate { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ExternalLoginTokenDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ExternalLoginTokenDto.cs
index b9ae050960..9699a6ef13 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ExternalLoginTokenDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ExternalLoginTokenDto.cs
@@ -31,7 +31,7 @@ internal class ExternalLoginTokenDto
[NullSetting(NullSetting = NullSettings.NotNull)]
public string Value { get; set; } = null!;
- [Column("createDate")]
+ [Column("createDate", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime CreateDate { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/KeyValueDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/KeyValueDto.cs
index 5c985a0174..6bab9b91be 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/KeyValueDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/KeyValueDto.cs
@@ -23,7 +23,7 @@ internal class KeyValueDto
[NullSetting(NullSetting = NullSettings.Null)]
public string? Value { get; set; }
- [Column("updated")]
+ [Column("updated", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime UpdateDate { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/LogDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/LogDto.cs
index 62f8232da5..36f637fef3 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/LogDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/LogDto.cs
@@ -35,7 +35,7 @@ internal class LogDto
[NullSetting(NullSetting = NullSettings.Null)]
public string? EntityType { get; set; }
- [Column("Datestamp")]
+ [Column("Datestamp", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
[Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_datestamp", ForColumns = "Datestamp,userId,NodeId")]
public DateTime Datestamp { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/MemberDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/MemberDto.cs
index 77b500eef5..5a025c412e 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/MemberDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/MemberDto.cs
@@ -45,7 +45,7 @@ internal class MemberDto
[Length(255)]
public string? SecurityStampToken { get; set; }
- [Column("emailConfirmedDate")]
+ [Column("emailConfirmedDate", ForceToUtc = false)]
[NullSetting(NullSetting = NullSettings.Null)]
public DateTime? EmailConfirmedDate { get; set; }
@@ -62,15 +62,15 @@ internal class MemberDto
[Constraint(Default = 1)]
public bool IsApproved { get; set; }
- [Column("lastLoginDate")]
+ [Column("lastLoginDate", ForceToUtc = false)]
[NullSetting(NullSetting = NullSettings.Null)]
public DateTime? LastLoginDate { get; set; }
- [Column("lastLockoutDate")]
+ [Column("lastLockoutDate", ForceToUtc = false)]
[NullSetting(NullSetting = NullSettings.Null)]
public DateTime? LastLockoutDate { get; set; }
- [Column("lastPasswordChangeDate")]
+ [Column("lastPasswordChangeDate", ForceToUtc = false)]
[NullSetting(NullSetting = NullSettings.Null)]
public DateTime? LastPasswordChangeDate { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/NodeDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/NodeDto.cs
index c136f45fd4..e140b3ec5d 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/NodeDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/NodeDto.cs
@@ -70,7 +70,7 @@ public class NodeDto
[Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_ObjectType", ForColumns = "nodeObjectType,trashed", IncludeColumns = "uniqueId,parentId,level,path,sortOrder,nodeUser,text,createDate")]
public Guid? NodeObjectType { get; set; }
- [Column("createDate")]
+ [Column("createDate", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime CreateDate { get; set; }
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/RelationDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/RelationDto.cs
index 59484734dc..51c36126d5 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/RelationDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/RelationDto.cs
@@ -27,7 +27,7 @@ internal class RelationDto
[ForeignKey(typeof(RelationTypeDto))]
public int RelationType { get; set; }
- [Column("datetime")]
+ [Column("datetime", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime Datetime { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ServerRegistrationDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ServerRegistrationDto.cs
index 66a8c2bd07..a91bfc6bd5 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/ServerRegistrationDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ServerRegistrationDto.cs
@@ -23,11 +23,11 @@ internal class ServerRegistrationDto
[Index(IndexTypes.UniqueNonClustered, Name = "IX_computerName")] // server identity is unique
public string? ServerIdentity { get; set; }
- [Column("registeredDate")]
+ [Column("registeredDate", ForceToUtc = false)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime DateRegistered { get; set; }
- [Column("lastNotifiedDate")]
+ [Column("lastNotifiedDate", ForceToUtc = false)]
public DateTime DateAccessed { get; set; }
[Column("isActive")]
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs
index fa8011be29..4972332566 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs
@@ -73,32 +73,32 @@ public class UserDto
[NullSetting(NullSetting = NullSettings.Null)]
public int? FailedLoginAttempts { get; set; }
- [Column("lastLockoutDate")]
+ [Column("lastLockoutDate", ForceToUtc = false)]
[NullSetting(NullSetting = NullSettings.Null)]
public DateTime? LastLockoutDate { get; set; }
- [Column("lastPasswordChangeDate")]
+ [Column("lastPasswordChangeDate", ForceToUtc = false)]
[NullSetting(NullSetting = NullSettings.Null)]
public DateTime? LastPasswordChangeDate { get; set; }
- [Column("lastLoginDate")]
+ [Column("lastLoginDate", ForceToUtc = false)]
[NullSetting(NullSetting = NullSettings.Null)]
public DateTime? LastLoginDate { get; set; }
- [Column("emailConfirmedDate")]
+ [Column("emailConfirmedDate", ForceToUtc = false)]
[NullSetting(NullSetting = NullSettings.Null)]
public DateTime? EmailConfirmedDate { get; set; }
- [Column("invitedDate")]
+ [Column("invitedDate", ForceToUtc = false)]
[NullSetting(NullSetting = NullSettings.Null)]
public DateTime? InvitedDate { get; set; }
- [Column("createDate")]
+ [Column("createDate", ForceToUtc = false)]
[NullSetting(NullSetting = NullSettings.NotNull)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime CreateDate { get; set; } = DateTime.Now;
- [Column("updateDate")]
+ [Column("updateDate", ForceToUtc = false)]
[NullSetting(NullSetting = NullSettings.NotNull)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime UpdateDate { get; set; } = DateTime.Now;
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs
index 548d2ff57d..cf66725f36 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs
@@ -44,12 +44,12 @@ public class UserGroupDto
[Obsolete("Is not used anymore Use UserGroup2PermissionDtos instead. This will be removed in Umbraco 18.")]
public string? DefaultPermissions { get; set; }
- [Column("createDate")]
+ [Column("createDate", ForceToUtc = false)]
[NullSetting(NullSetting = NullSettings.NotNull)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime CreateDate { get; set; }
- [Column("updateDate")]
+ [Column("updateDate", ForceToUtc = false)]
[NullSetting(NullSetting = NullSettings.NotNull)]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime UpdateDate { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/WebhookLogDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/WebhookLogDto.cs
index 8e409cd0b3..d5de4bd008 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/WebhookLogDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/WebhookLogDto.cs
@@ -1,4 +1,4 @@
-using NPoco;
+using NPoco;
using Umbraco.Cms.Core;
using Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations;
@@ -24,7 +24,7 @@ internal class WebhookLogDto
[NullSetting(NullSetting = NullSettings.NotNull)]
public string StatusCode { get; set; } = string.Empty;
- [Column(Name = "date")]
+ [Column(Name = "date", ForceToUtc = false)]
[Index(IndexTypes.NonClustered, Name = "IX_" + Constants.DatabaseSchema.Tables.WebhookLog + "_date")]
[NullSetting(NullSetting = NullSettings.NotNull)]
public DateTime Date { get; set; }
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs
index ffcc6447eb..fed80e753f 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/ContentBaseFactory.cs
@@ -39,11 +39,8 @@ internal class ContentBaseFactory
content.CreatorId = nodeDto.UserId ?? Constants.Security.UnknownUserId;
content.WriterId = contentVersionDto.UserId ?? Constants.Security.UnknownUserId;
-
- // Dates stored in the database are local server time, but for SQL Server, will be considered
- // as DateTime.Kind = Utc. Fix this so we are consistent when later mapping to DataTimeOffset.
- content.CreateDate = DateTime.SpecifyKind(nodeDto.CreateDate, DateTimeKind.Local);
- content.UpdateDate = DateTime.SpecifyKind(contentVersionDto.VersionDate, DateTimeKind.Local);
+ content.CreateDate = nodeDto.CreateDate;
+ content.UpdateDate = contentVersionDto.VersionDate;
content.Published = dto.Published;
content.Edited = dto.Edited;
@@ -55,7 +52,7 @@ internal class ContentBaseFactory
content.PublishedVersionId = publishedVersionDto.Id;
if (dto.Published)
{
- content.PublishDate = DateTime.SpecifyKind(publishedVersionDto.ContentVersionDto.VersionDate, DateTimeKind.Local);
+ content.PublishDate = publishedVersionDto.ContentVersionDto.VersionDate;
content.PublishName = publishedVersionDto.ContentVersionDto.Text;
content.PublisherId = publishedVersionDto.ContentVersionDto.UserId;
}
@@ -74,7 +71,7 @@ internal class ContentBaseFactory
}
///
- /// Builds a Media item from a dto and content type.
+ /// Builds an IMedia item from a dto and content type.
///
public static Core.Models.Media BuildEntity(ContentDto dto, IMediaType? contentType)
{
@@ -100,8 +97,8 @@ internal class ContentBaseFactory
content.CreatorId = nodeDto.UserId ?? Constants.Security.UnknownUserId;
content.WriterId = contentVersionDto.UserId ?? Constants.Security.UnknownUserId;
- content.CreateDate = DateTime.SpecifyKind(nodeDto.CreateDate, DateTimeKind.Local);
- content.UpdateDate = DateTime.SpecifyKind(contentVersionDto.VersionDate, DateTimeKind.Local);
+ content.CreateDate = nodeDto.CreateDate;
+ content.UpdateDate = contentVersionDto.VersionDate;
// reset dirty initial properties (U4-1946)
content.ResetDirtyProperties(false);
@@ -114,7 +111,7 @@ internal class ContentBaseFactory
}
///
- /// Builds a Member item from a dto and member type.
+ /// Builds an IMedia item from a dto and content type.
///
public static Member BuildEntity(MemberDto dto, IMemberType? contentType)
{
@@ -129,9 +126,7 @@ internal class ContentBaseFactory
content.Id = dto.NodeId;
content.SecurityStamp = dto.SecurityStampToken;
- content.EmailConfirmedDate = dto.EmailConfirmedDate.HasValue
- ? DateTime.SpecifyKind(dto.EmailConfirmedDate.Value, DateTimeKind.Local)
- : null;
+ content.EmailConfirmedDate = dto.EmailConfirmedDate;
content.PasswordConfiguration = dto.PasswordConfig;
content.Key = nodeDto.UniqueId;
content.VersionId = contentVersionDto.Id;
@@ -145,20 +140,14 @@ internal class ContentBaseFactory
content.CreatorId = nodeDto.UserId ?? Constants.Security.UnknownUserId;
content.WriterId = contentVersionDto.UserId ?? Constants.Security.UnknownUserId;
- content.CreateDate = DateTime.SpecifyKind(nodeDto.CreateDate, DateTimeKind.Local);
- content.UpdateDate = DateTime.SpecifyKind(contentVersionDto.VersionDate, DateTimeKind.Local);
+ content.CreateDate = nodeDto.CreateDate;
+ content.UpdateDate = contentVersionDto.VersionDate;
content.FailedPasswordAttempts = dto.FailedPasswordAttempts ?? default;
content.IsLockedOut = dto.IsLockedOut;
content.IsApproved = dto.IsApproved;
- content.LastLockoutDate = dto.LastLockoutDate.HasValue
- ? DateTime.SpecifyKind(dto.LastLockoutDate.Value, DateTimeKind.Local)
- : null;
- content.LastLoginDate = dto.LastLoginDate.HasValue
- ? DateTime.SpecifyKind(dto.LastLoginDate.Value, DateTimeKind.Local)
- : null;
- content.LastPasswordChangeDate = dto.LastPasswordChangeDate.HasValue
- ? DateTime.SpecifyKind(dto.LastPasswordChangeDate.Value, DateTimeKind.Local)
- : null;
+ content.LastLoginDate = dto.LastLoginDate;
+ content.LastLockoutDate = dto.LastLockoutDate;
+ content.LastPasswordChangeDate = dto.LastPasswordChangeDate;
// reset dirty initial properties (U4-1946)
content.ResetDirtyProperties(false);
@@ -197,7 +186,7 @@ internal class ContentBaseFactory
new ContentScheduleDto
{
Action = x.Action.ToString(),
- Date = DateTime.SpecifyKind(x.Date, DateTimeKind.Local),
+ Date = x.Date,
NodeId = entity.Id,
LanguageId = languageRepository.GetIdByIsoCode(x.Culture, false),
Id = x.Id,
@@ -272,7 +261,7 @@ internal class ContentBaseFactory
UserId = entity.CreatorId,
Text = entity.Name,
NodeObjectType = objectType,
- CreateDate = DateTime.SpecifyKind(entity.CreateDate, DateTimeKind.Local),
+ CreateDate = entity.CreateDate,
};
return dto;
@@ -286,7 +275,7 @@ internal class ContentBaseFactory
{
Id = entity.VersionId,
NodeId = entity.Id,
- VersionDate = DateTime.SpecifyKind(entity.UpdateDate, DateTimeKind.Local),
+ VersionDate = entity.UpdateDate,
UserId = entity.WriterId,
Current = true, // always building the current one
Text = entity.Name,
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/UserFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/UserFactory.cs
index 60ec173ca5..9a8ae11386 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/UserFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/UserFactory.cs
@@ -39,25 +39,16 @@ internal static class UserFactory
user.Language = dto.UserLanguage;
user.SecurityStamp = dto.SecurityStampToken;
user.FailedPasswordAttempts = dto.FailedLoginAttempts ?? 0;
+ user.LastLockoutDate = dto.LastLockoutDate;
+ user.LastLoginDate = dto.LastLoginDate;
+ user.LastPasswordChangeDate = dto.LastPasswordChangeDate;
+ user.CreateDate = dto.CreateDate;
+ user.UpdateDate = dto.UpdateDate;
user.Avatar = dto.Avatar;
user.EmailConfirmedDate = dto.EmailConfirmedDate;
user.InvitedDate = dto.InvitedDate;
user.Kind = (UserKind)dto.Kind;
- // Dates stored in the database are local server time, but for SQL Server, will be considered
- // as DateTime.Kind = Utc. Fix this so we are consistent when later mapping to DataTimeOffset.
- user.LastLockoutDate = dto.LastLockoutDate.HasValue
- ? DateTime.SpecifyKind(dto.LastLockoutDate.Value, DateTimeKind.Local)
- : null;
- user.LastLoginDate = dto.LastLoginDate.HasValue
- ? DateTime.SpecifyKind(dto.LastLoginDate.Value, DateTimeKind.Local)
- : null;
- user.LastPasswordChangeDate = dto.LastPasswordChangeDate.HasValue
- ? DateTime.SpecifyKind(dto.LastPasswordChangeDate.Value, DateTimeKind.Local)
- : null;
- user.CreateDate = DateTime.SpecifyKind(dto.CreateDate, DateTimeKind.Local);
- user.UpdateDate = DateTime.SpecifyKind(dto.UpdateDate, DateTimeKind.Local);
-
// reset dirty initial properties (U4-1946)
user.ResetDirtyProperties(false);
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/AuditRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/AuditRepository.cs
index e112e360d0..d7dc4f8161 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/AuditRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/AuditRepository.cs
@@ -29,7 +29,7 @@ internal class AuditRepository : EntityRepositoryBase, IAuditRe
List? dtos = Database.Fetch(sql);
- return dtos.Select(x => new AuditItem(x.NodeId, Enum.Parse(x.Header), x.UserId ?? Constants.Security.UnknownUserId, x.EntityType, x.Comment, x.Parameters, DateTime.SpecifyKind(x.Datestamp, DateTimeKind.Local))).ToList();
+ return dtos.Select(x => new AuditItem(x.NodeId, Enum.Parse(x.Header), x.UserId ?? Constants.Security.UnknownUserId, x.EntityType, x.Comment, x.Parameters, x.Datestamp)).ToList();
}
public void CleanLogs(int maximumAgeOfLogsInMinutes)
@@ -104,12 +104,12 @@ internal class AuditRepository : EntityRepositoryBase, IAuditRe
totalRecords = page.TotalItems;
var items = page.Items.Select(
- dto => new AuditItem(dto.NodeId, Enum.ParseOrNull(dto.Header) ?? AuditType.Custom, dto.UserId ?? Constants.Security.UnknownUserId, dto.EntityType, dto.Comment, dto.Parameters, DateTime.SpecifyKind(dto.Datestamp, DateTimeKind.Local))).ToList();
+ dto => new AuditItem(dto.NodeId, Enum.ParseOrNull(dto.Header) ?? AuditType.Custom, dto.UserId ?? Constants.Security.UnknownUserId, dto.EntityType, dto.Comment, dto.Parameters, dto.Datestamp)).ToList();
// map the DateStamp
for (var i = 0; i < items.Count; i++)
{
- items[i].CreateDate = DateTime.SpecifyKind(page.Items[i].Datestamp, DateTimeKind.Local);
+ items[i].CreateDate = page.Items[i].Datestamp;
}
return items;
@@ -149,7 +149,7 @@ internal class AuditRepository : EntityRepositoryBase, IAuditRe
LogDto? dto = Database.First(sql);
return dto == null
? null
- : new AuditItem(dto.NodeId, Enum.Parse(dto.Header), dto.UserId ?? Constants.Security.UnknownUserId, dto.EntityType, dto.Comment, dto.Parameters, DateTime.SpecifyKind(dto.Datestamp, DateTimeKind.Local));
+ : new AuditItem(dto.NodeId, Enum.Parse(dto.Header), dto.UserId ?? Constants.Security.UnknownUserId, dto.EntityType, dto.Comment, dto.Parameters, dto.Datestamp);
}
protected override IEnumerable PerformGetAll(params int[]? ids) => throw new NotImplementedException();
@@ -162,7 +162,7 @@ internal class AuditRepository : EntityRepositoryBase, IAuditRe
List? dtos = Database.Fetch(sql);
- return dtos.Select(x => new AuditItem(x.NodeId, Enum.Parse(x.Header), x.UserId ?? Constants.Security.UnknownUserId, x.EntityType, x.Comment, x.Parameters, DateTime.SpecifyKind(x.Datestamp, DateTimeKind.Local))).ToList();
+ return dtos.Select(x => new AuditItem(x.NodeId, Enum.Parse(x.Header), x.UserId ?? Constants.Security.UnknownUserId, x.EntityType, x.Comment, x.Parameters, x.Datestamp)).ToList();
}
protected override Sql GetBaseQuery(bool isCount)
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentRepository.cs
index 1b4f2b1efd..72459bd755 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentRepository.cs
@@ -400,17 +400,15 @@ public class DocumentRepository : ContentRepositoryBase 0 && contentVariations.TryGetValue(content.PublishedVersionId, out contentVariation))
{
foreach (ContentVariation v in contentVariation)
{
- content.SetPublishInfo(v.Culture, v.Name, DateTime.SpecifyKind(v.Date, DateTimeKind.Local));
+ content.SetPublishInfo(v.Culture, v.Name, v.Date);
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentVersionRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentVersionRepository.cs
index ef9dd67520..e922ed3cdb 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentVersionRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentVersionRepository.cs
@@ -1,4 +1,3 @@
-using System.Data;
using NPoco;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models;
@@ -99,16 +98,6 @@ internal class DocumentVersionRepository : IDocumentVersionRepository
Page? page =
_scopeAccessor.AmbientScope?.Database.Page(pageIndex + 1, pageSize, query);
- // Dates stored in the database are local server time, but for SQL Server, will be considered
- // as DateTime.Kind = Utc. Fix this so we are consistent when later mapping to DataTimeOffset.
- if (page is not null)
- {
- foreach (ContentVersionMeta item in page.Items)
- {
- item.SpecifyVersionDateKind(DateTimeKind.Local);
- }
- }
-
totalRecords = page?.TotalItems ?? 0;
return page?.Items;