Extend the now() function

now().hour only gives the hour in 24 hour format. A lot of posts refer to strftime and strptime, but I can’t seem to get these working with HASS.IO.

It would be useful if now() could return the time in 12 hour format. Two useful extensions would be

  • now().shorthour : returns hour in 12 hour format. E.g 3 rather than 15 for 3pm.

  • now().ampm : returns if it’s currently AM or PM

  • now().publicholiday : returns if it’s a public holiday