fix(posts): normalize PostDate to yyyy-MM-dd HH:mm:ss GMT
Text-file exports can carry RFC 1123 dates ("Fri, 14 Feb 2025 15:20:09 GMT"),
which sort on the weekday name and fall outside --fromDate/--toDate
comparisons. PostDates.Normalize converts them on every PostDate write path
(AddPost, UpsertPostFromTextFile, UpdatePostContentFields).
normalize-postdate.sql fixes the 4 existing rows.
Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
@@ -597,6 +597,7 @@ namespace URLNotesGrabberCORE
|
||||
{
|
||||
DBPath ??= GetDefaultDbPath();
|
||||
postType = PostTypes.Normalize(postType);
|
||||
postDate = PostDates.Normalize(postDate)!;
|
||||
try { AddBlog(blogName, byLikes, DBPath); } catch { }
|
||||
try { UpdatePostSetDate(blogName, postID, postDate, DBPath); } catch { }
|
||||
try { UpdatePost(blogName, postID, reblogURL, postDate, postURL, slug, reblogKey, reblogName, summary, quote, body, tags, link, photoURL, photoCaption, downloadedFiles, audioCaption, question, answer, title, hasImage, byLikes, DBPath, rootBlogName, rootURL, postType); } catch { }
|
||||
@@ -2249,6 +2250,7 @@ namespace URLNotesGrabberCORE
|
||||
// column. PostType is used as an output filename, so this is the invariant that keeps
|
||||
// a stray value from becoming a stray file.
|
||||
postType = PostTypes.Normalize(postType);
|
||||
postDate = PostDates.Normalize(postDate);
|
||||
try { AddBlog(blogName, false, DBPath); } catch { }
|
||||
|
||||
SQLiteConnection connection;
|
||||
@@ -2620,10 +2622,11 @@ namespace URLNotesGrabberCORE
|
||||
if (string.IsNullOrWhiteSpace(kvp.Value)) continue;
|
||||
string? column = MapPrefixToColumn(kvp.Key);
|
||||
if (column == null) continue;
|
||||
string value = column == "PostDate" ? PostDates.Normalize(kvp.Value)! : kvp.Value;
|
||||
string paramName = "@p" + parameters.Count;
|
||||
setClauses.Add($"{column} = {paramName}");
|
||||
changedClauses.Add($"IFNULL({column}, '') <> {paramName}");
|
||||
parameters.Add((paramName, kvp.Value));
|
||||
parameters.Add((paramName, value));
|
||||
}
|
||||
|
||||
if (setClauses.Count == 0) return false;
|
||||
|
||||
Reference in New Issue
Block a user