From 8f220d87290650e325c1f800707140c5f00a5778 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Sun, 25 Dec 2016 15:09:11 +0700 Subject: [PATCH] Install Date: Add an option to use 24h or 12h in time format --- config/config | 11 +++++++++++ neofetch | 16 ++++++++++++---- neofetch.1 | 3 +++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/config/config b/config/config index 8dfb19a9..2e33b74f 100644 --- a/config/config +++ b/config/config @@ -324,6 +324,17 @@ song_shorthand="off" # off: 'Thu 14 Apr 2016' install_time="on" +# Set time format in the output +# +# Default: '24h' +# Values: '12h', '24h' +# Flag: --install_time_format +# +# Example: +# 12h: 'Thu 14 Apr 2016 11:50 PM' +# 24h: 'Thu 14 Apr 2016 23:50' +install_time_format="24h" + # Text Colors diff --git a/neofetch b/neofetch index 9f7a31e4..d464f195 100755 --- a/neofetch +++ b/neofetch @@ -3058,9 +3058,14 @@ convert_time() { esac # Convert 24 hour time to 12 hour time + AM/PM. - case "$hour" in - [0-9] | 0[0-9] | 1[0-1]) time="${hour/00/12}${min} AM" ;; - *) time="$((hour - 12))${min} PM" ;; + case "$install_time_format" in + "12h") + case "$hour" in + [0-9] | 0[0-9] | 1[0-1]) time="${hour/00/12}${min} AM" ;; + *) time="$((hour - 12))${min} PM" ;; + esac + ;; + *) time="${hour}${min}" ;; esac # Toggle showing the time. @@ -3174,7 +3179,9 @@ INFO --shell_version on/off Enable/Disable showing \$SHELL version --ip_host url URL to query for public IP --song_shorthand on/off Print the Artist/Title on separate lines - --install_time on/off Enable/Disable showing the time in Install Date output. + --install_time on/off Enable/Disable showing the time in Install Date output. + --install_time_format 12h/24h + Set time format in Install Date to be 12 hour or 24 hour. TEXT FORMATTING @@ -3337,6 +3344,7 @@ get_args() { "--ip_host") public_ip_host="$2" ;; "--song_shorthand") song_shorthand="$2" ;; "--install_time") install_time="$2" ;; + "--install_time_format") install_time_format="$2" ;; "--disable") for func in "$@"; do case "$func" in diff --git a/neofetch.1 b/neofetch.1 index e19a2561..7384cd5d 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -96,6 +96,9 @@ Print the Artist/Title on separate lines .TP \fB\-\-install_time\fR on/off Enable/Disable showing the time in Install Date output. +.TP +\fB\-\-install_time_format\fR 12h/24h +Set time format in Install Date to be 12 hour or 24 hour. .PP TEXT FORMATTING .TP