Timer Script issue with trigger time

I have been trying to get some code that I got from here but have since modified to work for the past little while. I have two slightly different instances of this code running and one of them works but the other does not. The one that works is a timer script that is set to execute at the same time every day and other is supposed to trigger every hour. The hourly one is the one that doesn’t work, see the code below. The error I get when it try’s to execute is also copied below.

The code:
def checkTrigger():
import system
from java.util import Date

"Simple function to convert any timestamp to the trigger point on the same day"
def truncateToTrigger(ts):
	return Date(ts.year, ts.month, ts.date, ts.hour, 0, 0)
lastTrigPath = "Time stamp tag path"
last = system.tag.read(lastTrigPath).value
nextTrig = truncateToTrigger(last)
if nextTrig.time < last.time:
	nextTrig = system.date.addHours(nextTrig, 1)
now = Date()
if nextTrig.time <= now.time:
	system.tag.write(lastTrigPath, now)
	"my code here"


The fault msg:
Traceback (most recent call last):
line 23, in
line 12, in checkTrigger
line 8, in truncateToTrigger
AttributeError: ‘java.util.Date’ object has no attribute ‘hour’

Iv’e tried other ways to get around this fault but none seem to work correctly, and I haven’t been able to find any helpful resources on how the java.util.Date is structured to potentially point me in the right direction.

Try ts.hours

Thank you, I thought had tried that and it had given me the same type of fault but apparently not. I spent an embarrassing amount of time trying to figure that out. Thanks again.

That was my original code. I often post untested code–particularly after removing something customer-specific from a working example. If after discovering the error, I think the error message has enough info to solve my typo or whatever, I leave it as-posted, as an exercise for the reader.

You’re welcome. (: