• 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: Date mathematics help please...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Date mathematics help please...


  • Subject: Re: Date mathematics help please...
  • From: Kai <email@hidden>
  • Date: Sun, 19 Jan 2003 22:05:28 +0000

on Sat, 18 Jan 2003 17:51:07 -0600 (CST), montana <email@hidden>
wrote:

> I would like to take a start date/time like:
>
> 1.14.03 2100
>
> And an end date/time like;
>
> 1.17.03 2130
>
> I want to then take these two times and find their difference and return the
difference value in hours and minutes. (Diff -> 72h 30min)
>
> Does anyone know how to do this totally in AppleScript?

To deal with your particular date/time formats (which I assume will be
strings), you could try something like this:

=====================================

on hrsMins from s to e
set {x, y, z} to {date (s's word 1), date (e's word 1), ""}
set {x's time, y's time} to {getTime for s, getTime for e}
if x is greater than y then set {x, y, z} to {y, x, "-"}
tell y - x to z & it div hours & "h " & it mod hours div minutes & "min"
end hrsMins

to getTime for t
tell t's word -1 to it div 100 * hours + it mod 100 * minutes
end getTime

hrsMins from "1.14.03 2100" to "1.17.03 2130"

=====================================

--> "72h 30min" (U.S. System date format.)

--
Kai
_______________________________________________
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.

  • Prev by Date: re: UI scripting, windows order
  • Next by Date: AS to Change Owner of files
  • Previous by thread: Re: Date mathematics help please...
  • Next by thread: Applescript simple dialogs in Studio
  • Index(es):
    • Date
    • Thread