From 66bd68813839be18145c9fc8d116ad37ed4fca1b Mon Sep 17 00:00:00 2001 From: la-ninpre Date: Tue, 19 Apr 2022 01:14:39 +0300 Subject: rssg: fix date formatting use RSSG_DATE_IMPL environmental variable to set date(1) flavour of your choice. --- bin/rssg | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/bin/rssg b/bin/rssg index 099fe67..2d22a1a 100755 --- a/bin/rssg +++ b/bin/rssg @@ -2,6 +2,7 @@ # # https://www.romanzolotarev.com/bin/rssg # Copyright 2018 Roman Zolotarev +# Copyright 2022 la-ninpre # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -18,6 +19,7 @@ set -e set -x +[ -z "$RSSG_DATE_IMPL" ] && RSSG_DATE_IMPL="GNU" main () { test -n "$1" || usage @@ -118,8 +120,19 @@ rel_to_abs_urls() { date_rfc_822() { - date '+%a, %d %b %Y %H:%M:%S %z' \ - "$(echo "$1"| tr -cd '[:digit:]')0000" + _format='+%a, %d %b %Y %H:%M:%S %z' + _date="$1" + case "$RSSG_DATE_IMPL" in + "BSD") + _date="$(echo "$1" | tr -cd '[:digit:]')0000" + date -j "$_format" "$_date" + ;; + "GNU") + date -d "$_date" "$_format" + ;; + *) + ;; + esac } -- cgit v1.2.3