summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-04-10 16:37:23 -0300
committerEuAndreh <eu@euandre.org>2025-04-10 16:42:13 -0300
commitd10e5e21c4e0d52f6481297637e74c00cf986dfe (patch)
treee3290e77caa027b686ecb264eb0ccc346d51b534
parentsrc/sortdata: Require and assume that $sort is defined (diff)
downloadmkwb-d10e5e21c4e0d52f6481297637e74c00cf986dfe.tar.gz
mkwb-d10e5e21c4e0d52f6481297637e74c00cf986dfe.tar.xz
src/conf: Add ${date}_epoch alongside ${date}_iso data
-rwxr-xr-xsrc/conf12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/conf b/src/conf
index 9ddd305..a28087b 100755
--- a/src/conf
+++ b/src/conf
@@ -46,6 +46,10 @@ dateiso() {
datex "$1" -u "$DATE_Is"
}
+dateepoch() {
+ datex "$1" '+%s'
+}
+
CONF="${1:-}"
FILENAME="${2:-}"
eval "$(assert-arg -- "$CONF" 'CONF')"
@@ -69,6 +73,7 @@ needs "${sourcecode_url_prefix:-}" 'Missing required $sourcecode_url_prefix'
if [ "$GENERATE" = true ]; then
now_iso="$(dateiso "@${SOURCE_DATE_EPOCH:-$(date '+%s')}" | shesc)"
+ now_epoch="$(dateepoch "$now_iso" | shesc)"
feed_title_html="$(printf '%s\n' "$feed_title" | htmlesc | shesc)"
site_name_html="$( printf '%s\n' "$site_name" | htmlesc | shesc)"
if [ -z "${logo_alt:-}" ]; then
@@ -79,6 +84,7 @@ if [ "$GENERATE" = true ]; then
cat -- "$CONF"
cat <<-EOF
export now_iso="$now_iso"
+ export now_epoch="$now_epoch"
export feed_title_html="$feed_title_html"
export site_name_html="$site_name_html"
export feed_url_absolute="$url_pre/$feed_url"
@@ -144,15 +150,19 @@ url="$(printf '%s\n' "${UNPREFIXED%.adoc}.html" | shesc)"
collurl=
date_iso=
+date_epoch=
date_formatted=
updatedat_iso=
+updatedat_epoch=
updatedat_formatted=
if is_article; then
lastdirnames="$(last3dirnames)"
date_iso="$(dateiso "$lastdirnames" | shesc)"
+ date_epoch="$(dateepoch "$date_iso" | shesc)"
date_formatted="$(datefmt "$date_iso" | shesc)"
if [ -n "${updatedat:-}" ]; then
updatedat_iso="$(dateiso "$updatedat" | shesc)"
+ updatedat_epoch="$(dateepoch "$updatedat_iso" | shesc)"
updatedat_formatted="$(datefmt "$updatedat_iso" | shesc)"
fi
file="$(basename "$url")"
@@ -228,8 +238,10 @@ cat <<-EOF
export titlefull="$titlefull"
export titlefull_html="$titlefull_html"
export date_iso="$date_iso"
+ export date_epoch="$date_epoch"
export date_formatted="$date_formatted"
export updatedat_iso="$updatedat_iso"
+ export updatedat_epoch="$updatedat_epoch"
export updatedat_formatted="$updatedat_formatted"
export comment_url="$comment_url"
export discussions_url="$discussions_url"