CalendarLib question
CalendarLib question
- Subject: CalendarLib question
- From: Christian Boyce <email@hidden>
- Date: Mon, 26 Mar 2018 19:15:34 -0700
Does CalendarLIb (or CalendarLibEC) include the time zone in the event date? It
appears to me it does not. It's a problem for me because I'm writing a script
in Los Angeles, and running it on a machine in Texas, and even though the
events are created with the time zone specified as Pacific, when the machine in
Texas runs the script the times come out in Central Time (2 hours ahead of
Pacific). Here's my script:
use script "CalendarLib EC" version "1.1.3" -- put this at the top of your
scripts
use scripting additions
set today to current date
--
set {email_body, the_email_count, the_day, the_month, the_year} to {{}, 0, day
of today, month of today as integer, year of today}
set the_time to 0
set the time of today to the_time
--
-- if today is a Friday we want the appointments for tomorrow, and Sunday, and
Monday.
-- otherwise we just want the list for tomorrow.
--
set the_weekday to weekday of today as string
if the_weekday is "Friday" then
set tomorrow to today + 1 * days as date
set the_next_day to tomorrow + 3 * days as date
else
set tomorrow to today + 1 * days as date
set the_next_day to tomorrow + 1 * days as date
end if
--set the_list to every event whose start date is greater than tomorrow and
start date is less than the_next_day and summary starts with ""-- old slow way
set theStore to fetch store
set theCal to fetch calendar "CB & A" cal type cal cloud event store theStore
set the_list to fetch events starting date tomorrow ending date the_next_day
searching cals {theCal} event store theStore
set the_list to filter events by pattern event list the_list event summary "*"
without using regex
if the_list is not {} then
repeat with an_event in the_list
set event_info to event info for event an_event
set the_appointment_date to event_start_date of event_info --
does not seem to include time zone. Returns time
— two hours ahead when I run the script on a machine in Central Time.
--
-- do stuff here
--
end repeat
end if
(This script looks at my calendar— which I share with someone in Texas— and
gets all of the appointments for the next business day if they start with ).
If I run the script on a machine in the Pacific time zone, I get a (for
example):
event_start_date ==> date "Tuesday, March 27, 2018 at 3:00:00 PM"
If I run the script on a machine in the Central time zone I get the result==>
date "Tuesday, March 27, 2018 at 5:00:00 PM"
… and that happens even though the event info for the event knows that the time
zone is "Pacific/Los_Angeles".
It is easy enough for me to subtract two hours in the script. But I would like
a more universal solution.
I was tempted to get the machine's offset in seconds from GMT time and then do
something about it (if -18000 seconds, subtract two hours from the hour, if
-25200 do nothing) but then I wonder what will happen at Daylight Saving Time,
and I don't want to have 24 if statements. Everything I come up with seems to
have a weakness so I'm hoping that something in CalendarLib itself will help me
out.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden