Skip to content
This repository has been archived by the owner on May 27, 2023. It is now read-only.

Commit

Permalink
Added test for 12/24 hr format in Solar function #16
Browse files Browse the repository at this point in the history
  • Loading branch information
katernet committed Jan 13, 2019
1 parent da6a624 commit a3b1236
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions Darkmode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
## macOS Dark Mode at sunset
## Solar times pulled from Night Shift
## Author: katernet ## Version 1.8.1
## Author: katernet ## Version 1.8.2

## Global variables ##
darkdir=~/Library/Application\ Support/darkmode # darkmode directory
Expand Down Expand Up @@ -75,14 +75,12 @@ solar() {
riseT=$(/usr/bin/corebrightnessdiag nightshift-internal | grep nextSunrise | cut -d \" -f2)
setT=$(/usr/bin/corebrightnessdiag nightshift-internal | grep nextSunset | cut -d \" -f2)

# test 12 or 24 hour format
strig="M"
if [[ $riseT == *${strig}* ]];
then
formatT="%Y-%m-%d %H:%M:%S %p %z"
else
formatT="%Y-%m-%d %H:%M:%S %z"
fi
# Test for 12 or 24 hour format
if [[ $riseT == *M* ]] || [[ $setT == *M* ]]; then
formatT="%Y-%m-%d %H:%M:%S %p %z"
else
formatT="%Y-%m-%d %H:%M:%S %z"
fi

# Convert to local time
riseTL=$(date -jf "$formatT" "$riseT" +"%H:%M")
Expand Down

0 comments on commit a3b1236

Please sign in to comment.