Re: Getting human-understandable time from iCal
Re: Getting human-understandable time from iCal
- Subject: Re: Getting human-understandable time from iCal
- From: Martin Orpen <email@hidden>
- Date: Wed, 29 Sep 2004 10:10:05 +0100
on 29/9/04 3:48 am, Nigel Garvey at email@hidden
wrote:
> Martin Orpen wrote on Tue, 28 Sep 2004 13:02:25 +0100:
>
>> I'd like to be able to get the time between events in iCal in a more
>> "readable" format.
>>
>> I can easily get seconds between events:
>>
>> tell application "iCal"
>> set t1 to start date of first event of calendar 9 whose summary is
>> "xx01"
>> set t2 to start date of first event of calendar 9 whose summary is
>> "xx02"
>> set t3 to t2 - t1
>> end tell
>>
>> Can iCal be scripted to return years/months/days/hours/minutes/seconds?
>
> Vanilla AppleScript can:
Damn, you always seem to have these great routines to hand, especially with
maths stuff... :-)
[snip script]
It does it fast too, but it doesn't do it accurately enough:
--> date "Friday, February 28, 2003 11:30:00 am"
--> date "Tuesday, April 1, 2003 11:30:00 am"
--> "0 yr 1 mth 4 dy 0 hr 0 min 0 sec"
If you don't mind, I'm going to have a play with it and see if I can
incorporate some of the bits that I'd hacked together yesterday, like:
set nDays to {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
set lDays to {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
if y1 div 4 is 0 then
set mDays to lDays
else
set mDays to nDays
end if
Then do "86400*(item (month as integer) of mDays)" etc
To see if I can catch those pesky leap days and get a more accurate day
calculation.
Cheers
--
Martin Orpen
Idea Digital Imaging Ltd -- The Image Specialists
http://www.idea-digital.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden