Modify Sunrise/Sunset values to shortened format
Posted: Tue May 30, 2023 10:14 am
I am using a Python script to grab the next Sunset and Sunrise times from Indigo server to display on a custom page.
The value returned is in a long, 24 hour format like 2023-05-30 19:48:44
Trying to figure out how to modify that to a shortened, 12 hour format, that also strips the leading 0 if present, as well as seconds and write it to a variable.
So 2023-05-30 19:48:44 would become 7:48
Here is my current script:
Any help would be appreciated.
The value returned is in a long, 24 hour format like 2023-05-30 19:48:44
Trying to figure out how to modify that to a shortened, 12 hour format, that also strips the leading 0 if present, as well as seconds and write it to a variable.
So 2023-05-30 19:48:44 would become 7:48
Here is my current script:
- Code: Select all
sunset = indigo.server.calculateSunset() #Indigo Sunset
indigo.variable.updateValue(489151405, format(sunset)) #Sunset into Variable
Any help would be appreciated.