Skip to content

Commit

Permalink
[bash-timer] Added support for locales with the comma decimal separator.
Browse files Browse the repository at this point in the history
Fixes #6.
Addresses #7.
  • Loading branch information
hopeseekr committed Aug 29, 2024
1 parent 8f27474 commit ce23e97
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bash-timer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ bashtimer_preexec() {
# Thanks to /u/OneTurnMore
# https://www.reddit.com/r/bash/comments/ivz276/tired_of_typing_time_all_the_time_try_bashtimer/g5wui2l/
if [ ! -z "$EPOCHREALTIME" ]; then
# Replace "," decimal separator with ".". This is needed for European locales, among others.
EPOCHREALTIME="${EPOCHREALTIME/,/.}"

begin_s=${EPOCHREALTIME%.*}
begin_ns=${EPOCHREALTIME#*.}
begin_ns="${begin_ns#0}"
Expand All @@ -75,6 +78,9 @@ bashtimer_precmd() {
# Thanks to /u/OneTurnMore
# https://www.reddit.com/r/bash/comments/ivz276/tired_of_typing_time_all_the_time_try_bashtimer/g5wui2l/
if [ ! -z "$EPOCHREALTIME" ]; then
# Replace "," decimal separator with ".". This is needed for European locales, among others.
EPOCHREALTIME="${EPOCHREALTIME/,/.}"

end_s=${EPOCHREALTIME%.*}
end_ns=${EPOCHREALTIME#*.}
end_ns="${end_ns#0}"
Expand Down

0 comments on commit ce23e97

Please sign in to comment.