- TIME_CURRENT="$(date --iso-8601=seconds)" ; # Produce `date`-parsable current timestamp with resolution of 1 second.
- TIME_CURRENT_SHORT="$(date -d "$TIME_CURRENT" +%Y%m%dT%H%M%S%z)"; # Produce separator-less current timestamp with resolution 1 second.
- echo "$TIME_CURRENT_SHORT";
-} # Get date&time without separators
+ # Depends: yell
+ local argTime timeCurrent timeInput timeCurrentShort
+
+ argTime="$1";
+ # Get Current Time
+ timeCurrent="$(date --iso-8601=seconds)" ; # Produce `date`-parsable current timestamp with resolution of 1 second.
+ # Decide to parse current or supplied date
+ ## Check if time argument empty
+ if [[ -z "$argTime" ]]; then
+ ## T: Time argument empty, use current time
+ timeInput="$timeCurrent";
+ else
+ ## F: Time argument exists, validate time
+ if date --date="$argTime" 1>/dev/null 2>&1; then
+ ### T: Time argument is valid; use it
+ timeInput="$argTime";
+ else
+ ### F: Time argument not valid; exit
+ yell "ERROR:Invalid time argument supplied. Exiting."; exit 1;
+ fi
+ fi
+ # Construct and deliver separator-les date string
+ timeCurrentShort="$(date -d "$timeInput" +%Y%m%dT%H%M%S%z)";
+ echo "$timeCurrentShort";
+} # Get YYYYmmddTHHMMSS±zzzz