Hi,
I have a script that uploads files in a folder starting at 10 Pm. However, it’s still often running when I come in at 9 AM. For every file that the script prepares to upload, I want it to check the time, and if it’s between 9 AM and 10 PM, stop the script. Otherwise, proceed.
In attempting to get this time piece working, I’m just concentrating on that. But I don’t seem to be going about it correctly. I found a function that gets the time in hours and minutes, but I am not sure that’s the right way to go about this. This simple test is failing. Here’s what I have:
set a to getTimeInHoursAndMinutes()
if a > "9:00 AM" and a < "10:00 PM" then
return true
else
return false
end if
on getTimeInHoursAndMinutes()
-- Get the "hour"
set timeStr to time string of (current date)
set Pos to offset of ":" in timeStr
set theHour to characters 1 thru (Pos - 1) of timeStr as string
set timeStr to characters (Pos + 1) through end of timeStr as string
-- Get the "minute"
set Pos to offset of ":" in timeStr
set theMin to characters 1 thru (Pos - 1) of timeStr as string
set timeStr to characters (Pos + 1) through end of timeStr as string
--Get "AM or PM"
set Pos to offset of " " in timeStr
set theSfx to characters (Pos + 1) through end of timeStr as string
return (theHour & ":" & theMin & " " & theSfx) as string
end getTimeInHoursAndMinutes