Skip to content

Commit

Permalink
fix: Fix dates parsing on news listing/displaying (#229)
Browse files Browse the repository at this point in the history
Archweb recently switched date format from `01-01-2024` to `Jan. 01, 2024`, breaking the date parsing during the Arch news listing/displaying.
This commit updates the date parsing accordingly to fix the "invalid date" error during the news listing and the incorrect "Author/Date" fields when displaying a news.
  • Loading branch information
Antiz96 authored Sep 15, 2024
1 parent 0238738 commit ffce839
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/script/arch-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ list_news() {

if [ -n "${show_news}" ]; then
news_titles=$(echo "${news}" | htmlq -a title a | grep ^"View:" | sed "s/View:\ //g" | head -"${news_num}")
mapfile -t news_dates < <(echo "${news}" | htmlq td | grep -v "class" | grep "[0-9]" | sed "s/<[^>]*>//g" | head -"${news_num}" | xargs -I{} date -d "{}" "+%s")
mapfile -t news_dates < <(echo "${news}" | htmlq td | grep -v "class" | grep "[0-9]" | sed "s/<[^>]*>//g" | sed "s/\.//g" | head -"${news_num}" | xargs -I{} date -d "{}" "+%s")

echo
main_msg "$(eval_gettext "Arch News:")"
Expand Down Expand Up @@ -424,8 +424,8 @@ list_news() {
echo
warning_msg "$(eval_gettext "Unable to retrieve the selected Arch News (HTTP error response or request timeout)\nPlease, read the selected Arch News at \${news_url} before updating your system")"
else
news_author=$(echo "${news_content}" | htmlq -t .article-info | cut -f3- -d " ")
news_date=$(echo "${news_content}" | htmlq -t .article-info | cut -f1 -d " ")
news_author=$(echo "${news_content}" | htmlq -t .article-info | cut -f5- -d " ")
news_date=$(echo "${news_content}" | htmlq -t .article-info | cut -f1,2,3 -d " ")
news_article=$(echo "${news_content}" | htmlq -t .article-content)
title_tag="$(eval_gettext "Title:")"
author_tag="$(eval_gettext "Author:")"
Expand Down

0 comments on commit ffce839

Please sign in to comment.