Re: Human Readable Time snipit
Re: Human Readable Time snipit
- Subject: Re: Human Readable Time snipit
- From: Martin Orpen <email@hidden>
- Date: Sat, 14 Oct 2006 11:55:24 +0100
On 12 Oct 2006, at 01:31, kai wrote:
--------------
on dhms_format from s
tell ((date ("1 " & "1")) + (s * s) ^ 0.5) to tell (1000000 + (its
hours) * 10000 + (its minutes) * 100 + (its seconds)) as string to
(s div days as string) & ":" & text 2 thru 3 & ":" & text 4 thru 5
& ":" & text 6 thru 7
end dhms_format
dhms_format from 5.86574625E+8
--> "6789:01:23:45"
--------------
Or, for a more "human readable" result you could the
onCalendarInterval handler that Nigel posted in response to a problem
that I was having working out the intervals between iCal events many E
+ seconds ago:
------------
set startTime to date "Friday, January 1, 1904 00:00:00" -- trad Apple
set finishTime to startTime + 5.86574625E+8
set foo to calendarInterval(finishTime, startTime)
on calendarInterval(later, earlier)
if earlier comes after later then
set {later, earlier} to {earlier, later}
set sign to "-"
else
set sign to ""
end if
set y to (later's year) - (earlier's year)
copy later to b
set b's month to earlier's month
set m to (b - 2500000 - later) div -2500000 - 1
set d to (later's day) - (earlier's day)
set t to (later's time) - (earlier's time)
if t < 0 then set {d, t} to {d - 1, days + t}
set {h, min, s} to {t div hours, t mod hours div minutes, t mod
minutes}
if d < 0 then set {m, d} to {m - 1, d + (day of (later - (later's
day) * days))}
if m < 0 then set {y, m} to {y - 1, m + 12}
return sign & y & " yr " & m & " mth " & d & " dy " & h & " hr " &
min & " min " & s & " sec"
end calendarInterval
--> 18 yr 7 mth 2 dy 1 hr 23 min 45 sec
------------
--
Martin Orpen
Idea Digital Imaging Ltd
_______________________________________________
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