#!/usr/bin/env bash
# ISO date input validation
pattern='^(19|20)[0-9]{2}-(0[1-9]|10|11|12)-([012][0-9]|30|31)$'
while true; do
    read -p "Enter a date in ISO format (yyyy-mm-dd): " date
    if [[  "$date" =~ $pattern ]]; then
        break
    else
        echo "Invalid date, please try again."
    fi
done
echo "Date: $date"
