I have a date selection window that has two calendars on it that is used to select a time period for a KPI history report. ‘[color=#0000BF]HistoryStartDate[/color]’ & ‘[color=#0000BF]HistoryEndDate[/color]’ are the names of the calendars. I take the date from each and populate global tags and client tags with the dates selected in the calendar. Our production days start at 0600 each morning. What I’m trying to do is allow the users to select the date and then add the 06:00:00 as the time to each date when it is inserted into the tag value. I’m fairly new at scripting and have looked a lot of this up online however, I’m still having an issue with making it work. It will insert the date with 00:00:00 as the time to each tag I have in the script but I can’t get it to change the time. I know I could do this with dateArithmetic functions but I have several other places where I need to change the time using the calendar so I’m trying to learn it now. Any help with explanations for where I’ve gone wrong would be greatly appreciated. Thanks in advance.
Here’s my script I’m using:
#This script will set the Start & End dates for the local client
# tags "[Client]ClientStartDateSelect" & "[Client]ClientEndDateSelect"
#Imports the utility libraries into the java application
from java.util import *
# Gets the date selected from 'HistoryStartDate'
StartDate = event.source.parent.getComponent('HistoryStartDate').date
# Forces the time returned to be 0600 hrs.
cal = Calendar.getInstance()
cal.set(Calendar.HOUR_OF_DAY, 6)
cal.set(Calendar.MINUTE, 0)
cal.set(Calendar.SECOND, 0)
#Gets the date selected from 'HistoryEndDate'
EndDate = event.source.parent.getComponent('HistoryEndDate').date
# Forces the time returned to be 0600 hrs.
cal = Calendar.getInstance()
cal.set(Calendar.HOUR_OF_DAY, 6)
cal.set(Calendar.MINUTE, 0)
cal.set(Calendar.SECOND, 0)
# Sets the following tags to the selected date at 0600 hrs.
system.tag.writeToTag('Melamine/GlobalTags/HistoryStartDateSelected', StartDate)
system.tag.writeToTag('[Client]ClientStartDateSelect', StartDate)
system.tag.writeToTag('Melamine/GlobalTags/HistoryEndDateSelected', EndDate)
system.tag.writeToTag('[Client]ClientEndDateSelect', EndDate)
#Closes the HistoryDateSelect Window
system.nav.closeParentWindow(event)