Omni-calendar script small tweak needed

I found an almost perfect script to add my Omnifocus tasks with Due dates to a calendar. The only issue with the script is that if a due date does not have a time set, it is putting the calendar entry to 12am which is very out-of-site-out-of-mind. Is there any way to change this script so that un-timed tasks are set to either all-day events, or at least to early morning like 7 or 8am? Searching the Omnifocus applescript dictionary I can see no reference to due time. The script is by Rosemary Orchard:

property calendar_name : “OmniFocus” – This is the name of your calendar
property default_duration : 30 --minutes

– Rosemary Orchard
– Modified from a script by unlocked2412
– This creates calendar events for tasks which have a due date, if an estimated time is not set then the task defaults to 30 minutes in length

tell application “Calendar”
set calendar_element to calendar calendar_name
tell calendar calendar_name
set theEvents to every event
repeat with current_event in theEvents
delete current_event
end repeat
end tell
end tell

tell application “OmniFocus”
tell default document
set task_elements to flattened tasks whose ¬
(completed is false) and (due date ≠ missing value)
repeat with item_ref in task_elements
– GET OMNIFOCUS TASKS
set the_task to contents of item_ref
set task_name to name of the_task
set task_note to note of the_task
set task_due to due date of the_task
set task_estimate to estimated minutes of the_task
set task_url to “omnifocus:///task/” & id of the_task
if task_estimate is missing value then set task_estimate to default_duration
– BUILD CALENDAR DATE
set start_date to task_due
set end_date to start_date + (task_estimate * minutes)
– CREATE CALENDAR EVENT
tell application “Calendar”
tell calendar_element
if not (exists (first event whose (start date = start_date) and (summary = task_name))) then
make new event with properties ¬
{summary:task_name, start date:start_date, end date:end_date, url:task_url} at calendar_element
end if
end tell
end tell
end repeat
tell application “System Events”
display dialog “Done”
end tell
end tell
end tell

I am glad that you found this script useful for you. I am the original author of this script. I published it in May 2017.

Could you tell me more about this or show a screenshot where this specific scenario occurs ?

I looked some more and I think the problem may be coming from somewhere else. It looks like this is only happening with items that I’ve created using Kaitlin Salzke’s template plugin. I’m using it to create a project of tasks for clients as a wedding photographer. I give it the wedding date and can then assign that date -4wk for a meeting etc. When the plugin subtracts the 4 weeks to get the due date for that item it is giving it a 12am time. So this is probably not something you could fix directly for the template, though perhaps this script could take items assigned to 12am and set them to a time specified in a variable? Or even set them as full-day events? Not sure if that’s easy to do or not. Currently I only have 4 weddings so I’ve just manually fixed the times in Omnifocus, but that will become too much after a while. I’ve also contacted the plugin author to see if a fix could be done there. Thanks! I almost moved to Reminders for this just to have calendar entries, but I’d miss so many things in Omnifocus.

Thank you for explaining. Let me know if you need further help with the script. I would like that you don’t have to tweak things after if you have many projects going on. I guess that would be a lot of work.