Updated to work with 12h and 24h settings