diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2021-12-14 18:55:14 +0000 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2021-12-14 18:55:14 +0000 |
commit | 5bc93e78a6bc0bedd909d8ee79ea0c86aa00f02b (patch) | |
tree | 769c77955e8d497933aa2c1b34c3f417fd7ebf9d /bin | |
parent | c9af507f18643ad1340156041c4116ae2486a171 (diff) | |
download | rgoncalves.se-5bc93e78a6bc0bedd909d8ee79ea0c86aa00f02b.tar.gz |
bin/func: Add support for date + GNU Core Utils
Diffstat (limited to 'bin')
-rw-r--r-- | bin/func | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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() { |