From 5bc93e78a6bc0bedd909d8ee79ea0c86aa00f02b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Tue, 14 Dec 2021 18:55:14 +0000 Subject: bin/func: Add support for date + GNU Core Utils --- bin/func | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'bin') 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() { -- cgit v1.2.3