#18065: Fixing date handling in Live Writer

Work Item: 18065

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2011-12-01 12:16:25 -08:00
parent c7ed6013c8
commit b46281ce48
3 changed files with 33 additions and 5 deletions

View File

@@ -51,8 +51,8 @@ namespace Orchard.Core.Feeds.StandardBuilders {
public DateTime? PublishedUtc {
get {
if (_common != null && _common.PublishedUtc != null)
return _common.PublishedUtc;
if (_common != null && _common.CreatedUtc != null)
return _common.CreatedUtc;
return null;
}
}

View File

@@ -62,7 +62,7 @@ namespace Orchard.Core.Feeds.StandardQueries {
var items = _contentManager.Query()
.Where<CommonPartRecord>(x => x.Container == container.Record)
.OrderByDescending(x => x.PublishedUtc)
.OrderByDescending(x => x.CreatedUtc)
.Slice(0, limit);
foreach (var item in items) {

View File

@@ -216,10 +216,24 @@ namespace Orchard.Blogs.Services {
_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))
_blogPostService.Publish(blogPost);
if (publishedUtc != null) {
blogPost.As<CommonPart>().CreatedUtc = publishedUtc;
}
foreach (var driver in drivers)
driver.Process(blogPost.Id);
@@ -281,10 +295,24 @@ namespace Orchard.Blogs.Services {
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))
_blogPostService.Publish(blogPost);
if (publishedUtc != null) {
blogPost.As<CommonPart>().CreatedUtc = publishedUtc;
}
foreach (var driver in drivers)
driver.Process(blogPost.Id);