aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorla-ninpre <leobrekalini@gmail.com>2022-04-19 01:14:39 +0300
committerla-ninpre <leobrekalini@gmail.com>2022-04-19 01:19:47 +0300
commit66bd68813839be18145c9fc8d116ad37ed4fca1b (patch)
treedcdb9e2a5db0863da44fc01b931519c5c5d7d9e3
parente09c2afe5f6bc1782c8b7a4b7e8acb9d10e7c87d (diff)
downloadaaoth.xyz-66bd68813839be18145c9fc8d116ad37ed4fca1b.tar.gz
aaoth.xyz-66bd68813839be18145c9fc8d116ad37ed4fca1b.zip
rssg: fix date formatting
use RSSG_DATE_IMPL environmental variable to set date(1) flavour of your choice.
-rwxr-xr-xbin/rssg17
1 files 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 <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 @@ 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
}