# Check if schedule is active

**URL:** <https://forum.inductiveautomation.com/t/check-if-schedule-is-active/21967>\
**Category:** Ignition\
**Created:** [January 18, 2019, 10:48am UTC](https://forum.inductiveautomation.com/t/check-if-schedule-is-active/21967 "2019-01-18T10:48:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [January 18, 2019, 10:48am UTC](https://forum.inductiveautomation.com/t/check-if-schedule-is-active/21967/1 "2019-01-18T10:48:42Z")

</div>

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?

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

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

```

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [January 18, 2019, 2:36pm UTC](https://forum.inductiveautomation.com/t/check-if-schedule-is-active/21967/2 "2019-01-18T14:36:24Z")

</div>

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

[https://docs.inductiveautomation.com/display/DOC79/system.user.isUserScheduled](https://docs.inductiveautomation.com/display/DOC79/system.user.isUserScheduled)
