rssg: fix date formatting use RSSG_DATE_IMPL environmental variable to set date(1) flavour of your choice.
la-ninpre leobrekalini@gmail.com
Tue, 19 Apr 2022 01:14:39 +0300
1 files changed,
15 insertions(+),
2 deletions(-)
jump to
M
bin/rssg
→
bin/rssg
@@ -2,6 +2,7 @@ #!/bin/sh
# # https://www.romanzolotarev.com/bin/rssg # Copyright 2018 Roman Zolotarev <hi@romanzolotarev.com> +# Copyright 2022 la-ninpre <aaoth@aaoth.xyz> # # 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 @@ }
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 }