aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Gonçalves <me@rgoncalves.se>2021-12-14 18:55:14 +0000
committerRomain Gonçalves <me@rgoncalves.se>2021-12-14 18:55:14 +0000
commit5bc93e78a6bc0bedd909d8ee79ea0c86aa00f02b (patch)
tree769c77955e8d497933aa2c1b34c3f417fd7ebf9d
parentc9af507f18643ad1340156041c4116ae2486a171 (diff)
downloadrgoncalves.se-5bc93e78a6bc0bedd909d8ee79ea0c86aa00f02b.tar.gz
bin/func: Add support for date + GNU Core Utils
-rw-r--r--bin/func14
1 files changed, 12 insertions, 2 deletions
diff --git a/bin/func b/bin/func
index 4fe632e..62d65a0 100644
--- a/bin/func
+++ b/bin/func
@@ -20,6 +20,8 @@ website_language="en"
date_default_hour="17:00:00"
date_default_timezone="+0200"
+uname=$(uname)
+
__get_value() {
# 1: filename
# 2: Attribute name
@@ -60,7 +62,11 @@ __get_value_date() {
__get_value_date_human() {
# 1: filename
# Get a human readable date from a file and return a safe string.
- __get_value_date "${1}" | xargs date -j -f "%Y-%m-%d" +"%B %d, %Y"
+ if [ "${uname}" = "Linux" ]; then
+ __get_value_date "${1}" | xargs date +"%B %d, %Y" -d
+ else
+ __get_value_date "${1}" | xargs date -j -f "%Y-%m-%d" +"%B %d, %Y"
+ fi
}
__get_value_date_publication() {
@@ -71,7 +77,11 @@ __get_value_date_publication() {
_date="$(__get_value_date ${1})"
_date="${_date} ${date_default_hour} ${date_default_timezone}"
- date -j -f "%Y-%m-%d %H:%M:%S %z" +"%a, %d %b %Y %H:%M:%S %z" "${_date}"
+ if [ "${uname}" = "Linux" ]; then
+ date -d "${_date}" +"%a, %d %b %Y %H:%M:%S %z"
+ else
+ date -j -f "%Y-%m-%d %H:%M:%S %z" +"%a, %d %b %Y %H:%M:%S %z" "${_date}"
+ fi
}
__get_out_filename() {
remember that computers suck.