I'm trying to properly format "and" when it comes to reading time. I'd like to try to figure out how to only echo "and" before the last value (whether it be Hours, Minutes, or Seconds) and only if there's more than one value (need two values, ie: 2 Days, and 5 minutes, or 2 Days, 12 hours, and 5 minutes)

I don't know the proper syntax to say, if ONLY one of the values, H, M, and S is greater than 0, then $DAnd="and ".
This would be repeated for hours as well, so if ONLY of the values, M and S is greater than 0, then "$HAnd="and ".
For minutes, it's easy, as it's only checking to see if S is greater than 0.

How does one achieve this without making a large mess of code?

My current script:

```
#!/bin/bash
TIME1="08/15/2018 10:30:41"
TIME2="08/30/2018 8:34:40"
SEC1=`date +%s -d "${TIME1}"`
SEC2=`date +%s -d "${TIME2}"`
DIFF=`expr ${SEC2} - ${SEC1}`
CONVERTTIME()
{
  local T=$1
  local D=$((T/60/60/24))
  local H=$((T/60/60%24))
  local M=$((T/60%60))
  local S=$((T%60))
  if [[ $D > 0 ]]; then
    [[ ($H = 0 || $M = 0 || $S = 0) && ($H = 0 && $M = 0 && $S = 0) ]] && DComma="" || DComma=","
    #The problem
    [[ ($H > 0 || $M > 0 || $S > 0) && ($H = 0 || $M = 0 || $S = 0) ]] && DAnd="" || DAnd="and "
    [[ $D = 1 ]] && echo -n "$D day$DComma " || echo -n "$D days$DComma $DAnd"

  fi
  if [[ $H > 0 ]]; then
    [[ ($M = 0 || $S = 0) && ($M = 0 && $S = 0) ]] && HComma="" || HComma=","
    #The problem
    [[ ($M > 0 || $S > 0) && ($M = 0 || $S = 0) ]] && HAnd="" || HAnd="and "
    [[ $H = 1 ]] && echo -n "$H hour$HComma $HAnd" || echo -n "$H hours$HComma $HAnd"
  fi
  if [[ $M > 0 ]]; then
    [[ $S = 0 ]] && MComma="" || MComma=", and "
    [[ $M = 1 ]] && echo -n "$M minute$MComma" || echo -n "$M minutes$MComma"
  fi
  if [[ $S > 0 ]]; then
    [[ $S = 0 ]] && echo -n "$S second" || echo -n "$S seconds"
  fi
  # If no difference in time:
  [[ $D = 0 && $H = 0 && $M = 0 && $S = 0 ]] && echo -n "0 seconds"
  echo
}
echo
echo "TIME DIFFERENCE: $(CONVERTTIME $DIFF)"
echo

```