Skip to content

Commit

Permalink
Merge pull request #593 from poppastring/open-live-writer-timezoneadjust
Browse files Browse the repository at this point in the history
Change the look ahead calculation to not focus on "Time Zone" adjusting time.

close #592
  • Loading branch information
poppastring authored Nov 18, 2021
2 parents c3bb683 + 5220e46 commit 6ae2654
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,5 @@ source/DasBlog.Web.UI/content
test_results/
test_results.xml
/source/DasBlog.Tests/FunctionalTests/Properties/launchSettings.json
/source/DasBlog.Web.UI/Properties/ServiceDependencies/dasblog-linux - Zip Deploy/profile.arm.json
/source/DasBlog.Web.UI/Properties/ServiceDependencies/dasblog-linux - Zip Deploy
1 change: 1 addition & 0 deletions source/DasBlog.Services/IDasBlogSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ public interface IDasBlogSettings
string GeneratePostUrl(Entry entry);
SendMailInfo GetMailInfo(MailMessage emailmessage);
DateTime GetDisplayTime(DateTime datetime);
DateTime GetCreateTime(DateTime datetime);
}
}
5 changes: 5 additions & 0 deletions source/DasBlog.Tests/UnitTests/DasBlogSettingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,10 @@ public DateTime GetDisplayTime(DateTime datetime)
{
throw new NotImplementedException();
}

public DateTime GetCreateTime(DateTime datetime)
{
throw new NotImplementedException();
}
}
}
4 changes: 4 additions & 0 deletions source/DasBlog.Web.Repositories/XmlRpcManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ public string blogger_newPost(string appKey, string blogid, string username, str
newPost.IsPublic = publish;
newPost.Syndicated = publish;

newPost.CreatedUtc = newPost.ModifiedUtc = dasBlogSettings.GetCreateTime(newPost.CreatedUtc);

dataService.SaveEntry(newPost);

return newPost.EntryId;
Expand Down Expand Up @@ -614,6 +616,8 @@ public string metaweblog_newPost(string blogid, string username, string password

var trackbackList = FillEntryFromMetaWeblogPost(newPost, post);

newPost.CreatedUtc = newPost.ModifiedUtc = dasBlogSettings.GetCreateTime(newPost.CreatedUtc);

newPost.IsPublic = publish;
newPost.Syndicated = publish;

Expand Down
10 changes: 1 addition & 9 deletions source/DasBlog.Web.UI/Controllers/BlogPostController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,7 @@ public IActionResult CreatePost(PostViewModel post, string submit)
entry.Language = post.Language;
entry.Latitude = null;
entry.Longitude = null;

if (dasBlogSettings.SiteConfiguration.AdjustDisplayTimeZone)
{
entry.CreatedUtc = entry.ModifiedUtc = post.CreatedDateTime.AddHours(-1 * dasBlogSettings.SiteConfiguration.DisplayTimeZoneIndex);
}
else
{
entry.CreatedUtc = entry.ModifiedUtc = post.CreatedDateTime;
}
entry.CreatedUtc = entry.ModifiedUtc = dasBlogSettings.GetCreateTime(post.CreatedDateTime);

var sts = blogManager.CreateEntry(entry);
if (sts != NBR.EntrySaveState.Added)
Expand Down
19 changes: 11 additions & 8 deletions source/DasBlog.Web.UI/Settings/DasBlogSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,7 @@ public DateTimeZone GetConfiguredTimeZone()

public DateTime GetContentLookAhead()
{
if (SiteConfiguration.AdjustDisplayTimeZone)
{
return DateTime.UtcNow.AddHours(SiteConfiguration.DisplayTimeZoneIndex).AddDays(SiteConfiguration.ContentLookaheadDays);
}
else
{
return DateTime.UtcNow.AddDays(SiteConfiguration.ContentLookaheadDays);
}
return DateTime.UtcNow.AddDays(SiteConfiguration.ContentLookaheadDays);
}

public string FilterHtml(string input)
Expand Down Expand Up @@ -304,5 +297,15 @@ public DateTime GetDisplayTime(DateTime datetime)
}
return datetime;
}

public DateTime GetCreateTime(DateTime datetime)
{
if (SiteConfiguration.AdjustDisplayTimeZone)
{
datetime = datetime.AddHours(-1 * SiteConfiguration.DisplayTimeZoneIndex);
}

return datetime;
}
}
}

0 comments on commit 6ae2654

Please sign in to comment.