From ffce839c682e2286dc846a16ec2f2fa39cfb7ead Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 15 Sep 2024 20:46:49 +0200 Subject: [PATCH] fix: Fix dates parsing on news listing/displaying (#229) 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. --- src/script/arch-update.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index ff75b78..3c769bf 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -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:")" @@ -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:")"