mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-20 18:57:56 +08:00
#18065: Fixing date handling in Live Writer
Work Item: 18065 --HG-- branch : 1.x
This commit is contained in:
@@ -51,8 +51,8 @@ namespace Orchard.Core.Feeds.StandardBuilders {
|
|||||||
|
|
||||||
public DateTime? PublishedUtc {
|
public DateTime? PublishedUtc {
|
||||||
get {
|
get {
|
||||||
if (_common != null && _common.PublishedUtc != null)
|
if (_common != null && _common.CreatedUtc != null)
|
||||||
return _common.PublishedUtc;
|
return _common.CreatedUtc;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,7 @@ namespace Orchard.Core.Feeds.StandardQueries {
|
|||||||
|
|
||||||
var items = _contentManager.Query()
|
var items = _contentManager.Query()
|
||||||
.Where<CommonPartRecord>(x => x.Container == container.Record)
|
.Where<CommonPartRecord>(x => x.Container == container.Record)
|
||||||
.OrderByDescending(x => x.PublishedUtc)
|
.OrderByDescending(x => x.CreatedUtc)
|
||||||
.Slice(0, limit);
|
.Slice(0, limit);
|
||||||
|
|
||||||
foreach (var item in items) {
|
foreach (var item in items) {
|
||||||
|
@@ -216,10 +216,24 @@ namespace Orchard.Blogs.Services {
|
|||||||
|
|
||||||
_contentManager.Create(blogPost, VersionOptions.Draft);
|
_contentManager.Create(blogPost, VersionOptions.Draft);
|
||||||
|
|
||||||
var publishedUtc = content.Optional<DateTime?>("dateCreated");
|
// try to get the UTC timezone by default
|
||||||
|
var publishedUtc = content.Optional<DateTime?>("date_created_gmt");
|
||||||
|
if (publishedUtc == null) {
|
||||||
|
// take the local one
|
||||||
|
publishedUtc = content.Optional<DateTime?>("dateCreated");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// ensure it's read as a UTC time
|
||||||
|
publishedUtc = new DateTime(publishedUtc.Value.Ticks, DateTimeKind.Utc);
|
||||||
|
}
|
||||||
|
|
||||||
if (publish && (publishedUtc == null || publishedUtc <= DateTime.UtcNow))
|
if (publish && (publishedUtc == null || publishedUtc <= DateTime.UtcNow))
|
||||||
_blogPostService.Publish(blogPost);
|
_blogPostService.Publish(blogPost);
|
||||||
|
|
||||||
|
if (publishedUtc != null) {
|
||||||
|
blogPost.As<CommonPart>().CreatedUtc = publishedUtc;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var driver in drivers)
|
foreach (var driver in drivers)
|
||||||
driver.Process(blogPost.Id);
|
driver.Process(blogPost.Id);
|
||||||
|
|
||||||
@@ -281,10 +295,24 @@ namespace Orchard.Blogs.Services {
|
|||||||
blogPost.As<RoutePart>().Path = blogPost.As<RoutePart>().GetPathWithSlug(blogPost.As<RoutePart>().Slug);
|
blogPost.As<RoutePart>().Path = blogPost.As<RoutePart>().GetPathWithSlug(blogPost.As<RoutePart>().Slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
var publishedUtc = content.Optional<DateTime?>("dateCreated");
|
// try to get the UTC timezone by default
|
||||||
|
var publishedUtc = content.Optional<DateTime?>("date_created_gmt");
|
||||||
|
if (publishedUtc == null) {
|
||||||
|
// take the local one
|
||||||
|
publishedUtc = content.Optional<DateTime?>("dateCreated");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// ensure it's read as a UTC time
|
||||||
|
publishedUtc = new DateTime(publishedUtc.Value.Ticks, DateTimeKind.Utc);
|
||||||
|
}
|
||||||
|
|
||||||
if (publish && (publishedUtc == null || publishedUtc <= DateTime.UtcNow))
|
if (publish && (publishedUtc == null || publishedUtc <= DateTime.UtcNow))
|
||||||
_blogPostService.Publish(blogPost);
|
_blogPostService.Publish(blogPost);
|
||||||
|
|
||||||
|
if (publishedUtc != null) {
|
||||||
|
blogPost.As<CommonPart>().CreatedUtc = publishedUtc;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var driver in drivers)
|
foreach (var driver in drivers)
|
||||||
driver.Process(blogPost.Id);
|
driver.Process(blogPost.Id);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user