Skip to content

Commit

Permalink
Merge pull request #96 from stronk7/collations_grrr
Browse files Browse the repository at this point in the history
Some operations can fail if the date/time is not the expected one
  • Loading branch information
sarjona authored May 30, 2024
2 parents 33bbe63 + 86f9f81 commit f6c9a6b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ function next_utc_time() {
local time="${1}" # Time in HH:MM:SS format.
local now # Current time in seconds.
local next # To calculate the next time in seconds.
now=$(date -u +%s)
next=$(date -u -d "$(date -u -d @"${now}" +"%Y-%m-%d $time")" +%s)
now=$(LC_ALL=C date -u +%s)
next=$(LC_ALL=C date -u -d "$(LC_ALL=C date -u -d @"${now}" +"%Y-%m-%d $time")" +%s)
if [ "${now}" -gt "${next}" ]; then # If the time has already passed today.
next=$(date -u -d "$(date -u -d @"${next}") +1 day" +%s)
next=$(LC_ALL=C date -u -d "$(LC_ALL=C date -u -d @"${next}") +1 day" +%s)
fi
echo "${next}" # Return the next time in seconds.
}
4 changes: 2 additions & 2 deletions prerelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,11 @@ fi
# Before anything else, let's check if, right now, it's a good time to run this script.

# Calculate a few timestamps (unix seconds since epoch).
curr=$(date -u +%s) # Now
curr=$(LC_ALL=C date -u +%s) # Now
publ=$(next_utc_time "${PUBLISHING_TIME}") # Publishing time UTC.

# Calculate some local and interval times.
publlocal=$(date -d @"${publ}" +'%H:%M:%S %Z') # Publishing time in local time.
publlocal=$(LC_ALL=C date -d @"${publ}" +'%H:%M:%S %Z') # Publishing time in local time.
prevention=$((publ - PREVENT_MINUTES * 60)) # Begin of prevention time.

# If we are within the prevention time, let's prevent and exit.
Expand Down
6 changes: 3 additions & 3 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ for b in "${allbranches[@]}" ; do
# We very-rarely should face this, as far as the pre-release script already detects
# 99% of cases, but this is a last-resort check.
comm=$(git log -n1 --pretty=format:"%ct" origin/"${b}") # Last commit time in seconds.
curr=$(date -u +%s) # Now in seconds.
publ=$(date -u -d "${PUBLISHING_TIME}" +%s) # Publishing time in seconds.
publlocal=$(date -d @"${publ}" +'%H:%M:%S %Z') # Publishing time in local time.
curr=$(LC_ALL=C date -u +%s) # Now in seconds.
publ=$(LC_ALL=C date -u -d "${PUBLISHING_TIME}" +%s) # Publishing time in seconds.
publlocal=$(LC_ALL=C date -d @"${publ}" +'%H:%M:%S %Z') # Publishing time in local time.

if [ "${comm}" -lt "${publ}" ] && [ "${curr}" -gt "${publ}" ]; then
output " ${Y}Between the last commit and now, the packaging server${N}"
Expand Down

0 comments on commit f6c9a6b

Please sign in to comment.