Check if schedule is active

I wonder if there’s a better way to see if a user schedule is active inside a python script.

Currently I have this script to get a timeline from a schedule, and see if it’s active. It works but it’s not elegant (way too much date types used, and I have to go too deep in the Ignition classes).

Does someone have something more elegant?

import java.util.Date
import java.util.Calendar
import datetime
def isScheduleActive(scheduleName):
   now = java.util.Date()
   cal = java.util.Calendar.getInstance();  
   schedule = system.user.getSchedule("Example")
   timeline = schedule.getScheduleForDay(cal)

   dtNow =
   midnight = dtNow.replace(hour=0, minute=0, second=0, microsecond=0)
   msTime = (dtNow - midnight).seconds * 1000
   return timeline.getSegment(msTime, False) != None

not sure what version you are on but there is now a scripting function fo rthis