Skip to content

Commit

Permalink
pre: conv month 08 -> 8; 02 -> 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Jan 3, 2023
1 parent 2d7aef0 commit 87cf04f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/build/pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ name=`uname`

# timestamp: 1667519318.799 stackoverflow.com/a/69400542
# nowms =`date -u +"%s.%3N"`
if [[ $name == "Darwin" ]]
if [ $name = "Darwin" ]
then
now=`date -u +"%s"`
else
Expand All @@ -26,7 +26,7 @@ fi


# date from timestamp: stackoverflow.com/a/16311821
if [[ $name == "Darwin" ]]
if [ $name = "Darwin" ]
then
day=`date -r $now "+%d"`
else
Expand All @@ -37,19 +37,20 @@ day=${day#0}
# week; ceil: stackoverflow.com/a/12536521
wkdef=$(((day + 7 -1) / 7))
# year
if [[ $name == "Darwin" ]]
if [ $name = "Darwin" ]
then
yyyydef=`date -r $now "+%Y"`
else
yyyydef=`date -d @$now "+%Y"`
fi
# month
if [[ $name == "Darwin" ]]
if [ $name = "Darwin" ]
then
mmdef=`date -r $now "+%m"`
else
mmdef=`date -d @$now "+%m"`
fi
mmdef=${mmdef#0}

# defaults: stackoverflow.com/a/28085062
: "${wk:=$wkdef}" "${mm:=$mmdef}" "${yyyy:=$yyyydef}"
Expand Down

0 comments on commit 87cf04f

Please sign in to comment.