Re: Howto Display terminal return value??
Re: Howto Display terminal return value??
- Subject: Re: Howto Display terminal return value??
- From: Michelle Steiner <email@hidden>
- Date: Sat, 18 Jan 2003 17:17:37 -0700
On Saturday, January 18, 2003, at 04:45 PM, montana wrote:
Timecalc.py is a python script I wrote to calculate the difference
between two dates/time in the format (MM/dd/yy HHmm).
Oh, that's why I got an error when I removed the B (I had long since
removed the comma).
This program then returns the differnce between the two times in hours
and minutes. If anyone knows how to do this in Applescript that would
be great information too.
set startDate to getdate("start")
set endDate to getdate("end")
set elapsedTime to endDate - startDate
set hourslapsed to (elapsedTime / hours) div 1
set minslapsed to (elapsedTime - hourslapsed * hours) / minutes
set theAnswer to hourslapsed & " hours; " & minslapsed & " minutes." as
text
to getdate(startOrEnd)
set foo to date (text returned of (display dialog "enter the " &
startOrEnd & " date." default answer ""))
end getdate
With start as 1/1/03 2:03 am and end as 1/2/03 2:04 PM,
--> "36 hours; 1.0 minutes."
You might want to add some error checking to avoid input that can't be
translated to a date, and maybe to make sure that end is greater than
or equal to start.
--Michelle
--
"There's some good in the world, Mr. Frodo, and it's worth fighting
for."
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.