• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting human-understandable time from iCal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Getting human-understandable time from iCal
      • From: Paul Berkowitz <email@hidden>
References: 
 >Re: Getting human-understandable time from iCal (From: Nigel Garvey <email@hidden>)

  • Prev by Date: size of rich text messages
  • Next by Date: creating logs of all actions performed
  • Previous by thread: Re: Getting human-understandable time from iCal
  • Next by thread: Re: Getting human-understandable time from iCal
  • Index(es):
    • Date
    • Thread