Skip to content

Commit 3c154ec

Browse files
committed
Fix future-post warning to properly account for timezones
Previously the check only extracted YYYY-MM-DD from the front matter date, silently discarding any time and timezone offset. This caused false positives for NZ-timezone posts (e.g. "2026-03-05 00:00:00 +1300" is 2026-03-04 in UTC, but the check treated it as March 5) and false negatives for posts with negative UTC offsets. Now the full front matter date value is passed to GNU date with -u -d to get the correct UTC date, matching Jekyll's own behaviour. Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Sam Barker <sam@quadrocket.co.uk>
1 parent 0317f69 commit 3c154ec

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

.github/workflows/jekyll-gh-pages.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ jobs:
7777
for post in _posts/*.md; do
7878
filename=$(basename "$post")
7979
file_date=$(echo "$filename" | grep -oP '^\d{4}-\d{2}-\d{2}')
80-
front_matter_date=$(grep -oP '^date:\s*\K\d{4}-\d{2}-\d{2}' "$post" || true)
81-
# Use whichever date is later
82-
if [[ -n "$front_matter_date" && "$front_matter_date" > "$file_date" ]]; then
83-
post_date="$front_matter_date"
80+
# Extract the full front matter date value (may include time and timezone offset)
81+
# and convert to a UTC date so that e.g. "2026-03-05 00:00:00 +1300" is
82+
# correctly treated as 2026-03-04 in UTC (matching Jekyll's behaviour).
83+
front_matter_raw=$(grep -oP '^date:\s*\K.+' "$post" | xargs 2>/dev/null || true)
84+
if [[ -n "$front_matter_raw" ]]; then
85+
post_date=$(date -u -d "$front_matter_raw" +%Y-%m-%d 2>/dev/null || echo "$file_date")
8486
else
8587
post_date="$file_date"
8688
fi

0 commit comments

Comments
 (0)