Selecting a date with a default time using a calendar

I’ll apologize up front if this is simple. I’m new to Ignition and have very limited scripting knowledge but I am learning quickly!
I want to allow my users to select a date from a calander to use as a start date to pull history from previous shifts. Our shifts start and end at 6AM & 6PM. I want to take the date they select and turn the date/time produced into “(date selected) 6:00:00 AM” and insert that into my global_start_date tag as a datetime type to be called and used in other functions. So far I have been able to use the calendar function and insert the date selected but it also uses the current hour/minute/second as the time for the date selected. I’ve tried to look up help on parsing the date out of a Now() statement and inserting an actual time (such as 6:00:00 AM) to the finished variable but I’m having trouble connecting the dots. Any help or insight would be greatly appreciated.

If you set the calendar’s Time Style to Start of Day, it will always default to 12:00AM. You can then use the dateArithmetic function in an expression to offset the start of shift.

In the internalFrameActivated event for the window, I put the following code.

from java.util import Calendar cal = Calendar.getInstance() cal.add(Calendar.HOUR, -168) cal.set(Calendar.HOUR_OF_DAY, 7) cal.set(Calendar.MINUTE, 0) cal.set(Calendar.SECOND, 0) system.gui.getParentWindow(event).getComponentForPath('Root Container.Calendar').date = cal.getTime()

This subtracts exactly one week from the current time and sets the calendar to 7:00 am on that day.

I too am very much a noob when it comes to this scripting. I was able to put this together by using an example on page 753 of the most recent Ignition manual and filled in the gaps with info I found here…

http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html

Teach a man to fish…

I too had difficulty getting the now() function to work. IA tech support had to explain to me that now() is part if Ignition’s expression language and NOT part of the scripting language. Certainly not intuitive.