From: Steven Baltakatei Sandoval Date: Thu, 2 Jul 2020 20:10:00 +0000 (+0000) Subject: feat(unitproc):timeDuration:Remove unused boolean vars X-Git-Tag: 0.2.0~3 X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/25ecb96fab6571c9ccb7086e55187ac872ef00ad?ds=inline;hp=96716339c09aef0877825dafa92302dafcdb46c2 feat(unitproc):timeDuration:Remove unused boolean vars --- diff --git a/unitproc/bktemp-timeDuration b/unitproc/bktemp-timeDuration index 090b485..25740ff 100644 --- a/unitproc/bktemp-timeDuration +++ b/unitproc/bktemp-timeDuration @@ -10,13 +10,13 @@ timeDuration(){ # Ref/Attrib: ISO-8601:2004(E), §4.4.4.2 Representations of time intervals by duration and context information # Note: "1 month" ("P1M") is assumed to be "30 days" (see ISO-8601:2004(E), §2.2.1.2) # Usage: timeDuration [arg1] ([arg2]) - # Version: 1.0.0 + # Version: 1.0.1 # Input: arg1: seconds as base 10 integer >= 0 (ex: 3601) # arg2: precision level (optional; default=2) # Output: stdout: ISO-8601 duration string (ex: "P1H1S", "P2Y10M15DT10H30M20S") # Example: 'timeDuration 111111 3' yields 'P1DT6H51M' # Depends: date 8 (gnucoreutils), yell, - local returnState ARG1 ARG2 arg1Valid arg2Valid remainder precision witherPrecision + local returnState ARG1 ARG2 remainder precision witherPrecision local fullYears fullMonths fullDays fullHours fullMinutes fullSeconds local displayYears displayMonths displayDays displayHours displayMinutes displaySeconds local hasYears hasMonths hasDays hasHours hasMinutes hasSeconds @@ -33,13 +33,12 @@ timeDuration(){ # Check that arg1 provided if [[ $# -ge 1 ]]; then - # Check that arg1 is a positive integer + ## Check that arg1 is a positive integer if [[ "$ARG1" =~ ^[[:digit:]]+$ ]]; then - arg1Valid="true"; + : else yell "ERROR:ARG1 not a digit."; returnState="ERROR_INPUT"; - arg1Valid="false"; fi else yell "ERROR:No argument provided. Exiting."; @@ -50,15 +49,13 @@ timeDuration(){ if [[ $# -eq 2 ]]; then # Check that the second arg is a positive integer if [[ "$ARG2" =~ ^[[:digit:]]+$ ]] && [[ "$ARG2" -gt 0 ]]; then - arg2Valid="true"; precision="$ARG2"; else yell "ERROR:ARG2 not a positive integer. (is $ARG2 ). Leaving early."; returnState="ERROR_INPUT"; - arg2Valid="false"; fi; else - arg2Valid="false"; + : fi; remainder="$ARG1" ; # seconds