Skip to content

Commit

Permalink
Call fully qualified date on Darwin (#19)
Browse files Browse the repository at this point in the history
When GNU coreutils are installed and in the users $PATH, using `date` unqualified will lead to errors, as -j is an invalid option.
  • Loading branch information
johanfriis authored Sep 25, 2024
1 parent 3cdf022 commit 760447b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assume-aws-sso-role
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ iso_8601_to_rfc_822_date() {

date_to_seconds() {
if [ "${platform}" = Darwin ]; then
date -j -f "%FT%T%z" "$(iso_8601_to_rfc_822_date "$1")" "+%s"
/bin/date -j -f "%FT%T%z" "$(iso_8601_to_rfc_822_date "$1")" "+%s"
else
date -d "$1" "+%s" 2>/dev/null || gdate -d "$expiration" "+%s"
fi
}

local_time_for() {
if [ "${platform}" = Darwin ]; then
date -j -f "%FT%T%z" "$(iso_8601_to_rfc_822_date "$1")"
/bin/date -j -f "%FT%T%z" "$(iso_8601_to_rfc_822_date "$1")"
else
date -d "$1"
fi
Expand Down

0 comments on commit 760447b

Please sign in to comment.