Doty (date-of-the-year, HasyUtils.getDoty()) is a real number encoding date-time, e.g. 28.12 corresponds to Jan 29, 02:52. It is used for the x-value of some quantity that is monitored. This is how doty is converted to a human readable string
import datetime
def doty2datetime(doty, year = None):
"""
Convert the fractional day-of-the-year to a datetime structure
"""
if year is None:
now = datetime.datetime.now()
year = now.year
dotySeconds = doty*24.*60.*60
boy = datetime.datetime(year, 1, 1)
return boy + datetime.timedelta(seconds=dotySeconds)
a = doty2datetime( 28.12)
m = [ 'Jan', 'Feb', 'Mar', 'Aptr', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
print( "%s %d, %02d:%02d" % (m[ a.month - 1], a.day, a.hour, a.minute))
--> Jan 29, 02:52