Want to edit plain text list of many event times--EST to PST

Have a plain text document containing a whole bunch of event start and end times. The times are in Eastern Time.
I would like to do a find/replace to convert these times from Eastern Time to Pacific Time.

The text list is formated thus:
(excepting the time “##:##[Space]?M”, all Spaces below are for readability)

6:15 AM [one Tab] Event-name [one Return]
Event-summary [one Tab] End [one Tab] 6:35 AM [two Returns]
6:45 AM …same as above
7:30 AM …same
8:20 AM …
…and continuing
10:30 AM …
11:45 AM …
12:00 PM …
1:00 PM
…and continuing
2:45 PM
6:30 PM
9:30 PM
10:00 PM
12:00 AM …
…and continuing to the following day’s events.

I tried Tex-Edit Plus and BBEdit’s Grep search/replace without much luck – Grep won’t do math. :confused:

I’m purdy dang sure AppleScript can figure this out – I have done a little AppleScripting. However, this one is behond my head.
As I see it, some kind of string-to-numeric conversion is needed and then the time shift subtraction (3 hours) to get to PST.

Thanks very much,

Model: Power Mac G4 Dual 1.42 GHz
AppleScript: 2.0
Browser: Safari
Operating System: Mac OS X (10.3.9)

Just thinking out loud…

Any possibility of getting the events reported in military (24 hour) format?

If not, make it into 24 hr format by adding 12 to the hours if there is a PM on the line, then subtract 3 hours and reformat.

I expect an AS guru will chime in and give you a solution, but I am over my head as well.

Andy

Model: G5 Dual 2.7 GHz
AppleScript: 2.0 (v43.1)
Browser: Safari 312
Operating System: Mac OS X (10.4)

Hi,

Here’s an example of converting your example text. Note that the start times are the first text items in tab delimited fields for each event.

set t to "6:15 AM Event-name
Event-summary End 6:35 AM

6:15 AM Event-name
Event-summary End 6:35 AM

6:15 AM Event-name
Event-summary End 6:35 AM"
set def_tid to AppleScript’s text item delimiters
– get an event list
set AppleScript’s text item delimiters to {return & return}
set event_list to text items of t
– convert times to pacific tiem i.e. subtract 3 hours
set new_list to {}
repeat with this_event in event_list
– separate the start and end times of tab delimited text
set AppleScript’s text item delimiters to {tab}
set item_list to text items of this_event
set AppleScript’s text item delimiters to def_tid
tell item_list
set {start_time, end_time} to {item 1, item -1}
end tell
– convert to applescript date for subtraction
set {start_date, end_date} to {date start_time, date end_time}
– optional: check if end date should fall on next day
if end_date < start_date then
set end_date to (end_date + 1 * days)
end if
– subtract 3 hours from the dates and convert to text
set {pacific_start, pacific_end} to ¬
{time string of (start_date - 3 * hours), time string of (end_date - 3 * hours)}
– replace list item for this event
tell item_list
set {item 1, item -1} to {pacific_start, pacific_end}
end tell
– coerce list to tab delimited text
set AppleScript’s text item delimiters to {tab}
set new_event to item_list as string
set AppleScript’s text item delimiters to def_tid
– add modified text to the new list
set end of new_list to new_event
end repeat
– coerce the new list to blank line sepearated event text (double return)
set AppleScript’s text item delimiters to {return & return}
set new_text to new_list as string
set AppleScript’s text item delimiters to def_tid
– write the new text to file
return new_text

I didn’t know if you needed help with the reading and writing to text file part.

gl,