-- normalize-postdate.sql -- Rewrites Posts.PostDate values held in RFC 1123 form ("Fri, 14 Feb 2025 15:20:09 GMT") -- into the column's canonical "yyyy-MM-dd HH:mm:ss GMT" (the Tumblr API's own format). -- -- As of 2026-09-21 this matched 4 rows, all zombaee, from one text-file import. As text -- they sort on the weekday name and never satisfy --fromDate / --toDate comparisons. -- New writes are normalized in code by PostDates.Normalize, so this is a one-off. -- -- Only PostDate changes. DateModified is left alone: the post content did not change. -- -- HOW TO RUN: back up TL.db, then from the URLNotesGrabberCORE project folder: -- sqlite3 TL.db < ../normalize-postdate.sql SELECT 'before', COUNT(*) FROM Posts WHERE PostDate LIKE '___, __ ___ ____ __:__:__ GMT'; BEGIN; UPDATE Posts SET PostDate = substr(PostDate, 13, 4) || '-' || printf('%02d', (instr('JanFebMarAprMayJunJulAugSepOctNovDec', substr(PostDate, 9, 3)) + 2) / 3) || '-' || substr(PostDate, 6, 2) || ' ' || substr(PostDate, 18) WHERE PostDate LIKE '___, __ ___ ____ __:__:__ GMT' AND instr('JanFebMarAprMayJunJulAugSepOctNovDec', substr(PostDate, 9, 3)) % 3 = 1; COMMIT; -- VERIFY: expect 0, then a single shape '9999-99-99 99:99:99 GMT' (plus any NULL/blank) SELECT 'after', COUNT(*) FROM Posts WHERE PostDate LIKE '___, %'; SELECT CASE WHEN PostDate GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] GMT' THEN 'yyyy-MM-dd HH:mm:ss GMT' ELSE IFNULL(PostDate, '(null)') END AS shape, COUNT(*) FROM Posts GROUP BY 1 ORDER BY 2 DESC;