diff options
| author | la-ninpre <leobrekalini@gmail.com> | 2022-04-19 01:14:39 +0300 |
|---|---|---|
| committer | la-ninpre <leobrekalini@gmail.com> | 2022-04-19 01:19:47 +0300 |
| commit | 66bd68813839be18145c9fc8d116ad37ed4fca1b (patch) | |
| tree | dcdb9e2a5db0863da44fc01b931519c5c5d7d9e3 | |
| parent | e09c2afe5f6bc1782c8b7a4b7e8acb9d10e7c87d (diff) | |
| download | aaoth.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-x | bin/rssg | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -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 } |
