def hour_rounder(t):
# Rounds to nearest hour by adding a timedelta hour if minute >= 30
dt = t.replace(second=0, microsecond=0, minute=0, hour=t.hour) + timedelta(hours=t.minute // 30)
ts = int(dt.timestamp())
return str(ts)
print(hour_rounder(datetime.now()))