Subject: | |
From: | |
Reply To: | |
Date: | Wed, 21 May 2003 18:31:12 -0400 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
>I'm trying to coerce a string ("05212003") into a date (date "Wednesday, May
>21, 2003 12:00:00 AM"). Can that be done with a variation of the syntax
>above?
Hey, I just did something like that. It's in here somewhere.
on open fileList
repeat with onefile in fileList
tell application "Finder"
set thetype to file type of onefile
end tell
if thetype is "vCal" then
open for access onefile
set eofOneFile to (get eof file onefile)
--read onefile until eof
read file onefile for eofOneFile
copy result to clipText
close access onefile
end if
--display dialog the clipText -- for testing
end repeat
-- get the event name
set ClipStart to (offset of "SUMMARY:" in clipText) + (length of
"Summary:")
set clipText to text ClipStart thru end of clipText
set ClipEnd to ((offset of ASCII character 10 in clipText) - 2)
--exclude return and linefeed char
set TheEvent to (text 1 thru ClipEnd) of clipText
--get the event date and time
set ClipStart to (offset of "DTSTART:" in clipText) + (length of
"DTSTART:")
set clipText to text ClipStart thru end of clipText
set ClipEnd to ((offset of ASCII character 10 in clipText) - 3) --
eliminate the linefeed and "Z"
set DateTimeStart to (text 1 thru ClipEnd) of clipText
set AppleScript's text item delimiters to "T" -- find "T" in TimeStart
to seperate date from time
set DateTimeStart to text items of DateTimeStart
set ItemDate to item 1 of DateTimeStart
set EventDate to text 5 thru 6 of ItemDate & "/" & text 7 thru 8 of
ItemDate & "/" & text 3 thru 4 of ItemDate -- mm/dd/yy
set TimeStart to text 1 thru 2 of item 2 of DateTimeStart -- the time
portion
set EventStart to (text 1 thru 2 of TimeStart) - 5 --(time to GMT)
--display dialog "1: " & EventStart
if EventStart < 1 then set EventStart to (24 + EventStart)
if EventStart < 13 then
set DayPortion1 to "AM"
else
set EventStart to EventStart - 12
set DayPortion1 to "PM"
end if
--display dialog "2: " & EventStart
set EventStart to (EventStart as string) & ":" & text 3 thru 4 of item 2
of DateTimeStart
-- get event end time
set ClipStart to (offset of "DTEND:" in clipText) + (length of "DTEND:")
--what if no end time?
set clipText to text (ClipStart + 2) thru end of clipText -- eliminate
"TO" at begininning
set ClipEnd to ((offset of ASCII character 10 in clipText) - 3) --
eliminate "Z" at end
set DateTimeEnd to (text 1 thru ClipEnd) of clipText
--display dialog clipText
set AppleScript's text item delimiters to "T" -- find "T" in TimeStart
to seperate date from time
set DateTimeEnd to text items of DateTimeEnd
--display dialog item 2 of DateTimeEnd
set TimeEnd to text 1 thru 2 of item 2 of DateTimeEnd
--display dialog "TimeEnd: " & TimeEnd
set EventEnd to (text 1 thru 2 of TimeEnd) - 5 --(time to GMT)
--display dialog "3: " & EventEnd
if EventEnd < 1 then set EventEnd to (24 + EventEnd)
--display dialog "5: " & EventEnd
if EventEnd < 13 then
set DayPortion2 to "AM"
else
set EventEnd to EventEnd - 12
set DayPortion2 to "PM"
end if
set EventEnd to (EventEnd as string) & ":" & text 3 thru 4 of item 2 of
DateTimeEnd
--display dialog TheEvent & return & EventDate & return & EventStart & "
" & DayPortion1 & return & EventEnd & " " & DayPortion2
tell application "Finder"
--open (a reference to file "Mooch:Applications:HyperCard:HyperCard
Stacks:NewsClips")
open (a reference to file "Earl:More Apps:Stacks 2:ToDo Suite:To do be
do be do")
--open file "To do be do be do" of folder "To Do Suite" of folder
"Stacks 2" of folder "More Apps" of --startup disk of application "Finder"
end tell
tell application "HyperCard"
go card "Doug"
copy field "theItems" & return & TheEvent to field "theItems"
copy field "doItByDate" & return & EventDate to field "doItByDate"
copy field "TimeStart" & return & EventStart & " " & DayPortion1 to
field "TimeStart"
copy field "TimeEnd" & return & EventEnd & " " & DayPortion2 to field
"TimeEnd"
end tell
tell application "Finder"
--repeat with onefile in fileList
delete onefile
--end repeat
end tell
end open
end open
> <samu at golden.net> <http://home.golden.net/~samu> <
> There's a crack in everything. That's how the light gets in. <
|
|
|