+ local path=$1
+ # Use -u from bash top prevent empty expansion of variable yielding a
+ # list of current directory from find.
+ set -u
+ find $path -mindepth 1 -maxdepth 1 -exec rm -rf '{}' \;
+ set +u
+}
+
+# The extglob shell option must be enabled to use the pattern generated by this
+# function (shopt -s extglob/ shopt -u extglob).
+# The pattern returned by this function is to validate the form:
+# YYYYMMDDTHHMMSS[+-]HHMM-YYYYMMDDTHHMMSS[+-]HHMM
+#
+# Where YYYYMMDD is today or tomorrow. Tomorrow must be supported in case where
+# the chunks are generated close to midnight and one ends up the following day.
+function get_chunk_pattern ()
+{
+ local today=$1
+ tommorow=$(date +%Y%m%d -d "${today}+1days")
+ pattern_hour_min="[0-9][0-9][0-9][0-9]"
+ pattern_hour_min_sec="${pattern_hour_min}[0-9][0-9]"
+
+ base_pattern="@(${today}|${tommorow})T${pattern_hour_min_sec}[+-]${pattern_hour_min}"