• 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: Deivy Petrescu <email@hidden>
  • Date: Sun, 19 Jan 2003 00:54:27 -0500

At 17:51 -0600 1/18/03, montana wrote:
Hi Everyone-

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? I've written scripts in both Python and Java that accomplish this (with Python taking much less lines of code than Java to accomplish this task:)) but I would like to do this totally in AppleScript to access some of the gui features of OSX without alot of code; i.e. Dialogs.

Thanks.
SA
:)


hi,
I came up with this. You can see the pattern:


set l to date "Tuesday, January 14, 2003 21:00:12"
set m to date "Friday, January 17, 2003 21:30:00"
set ktime to m - l
if ktime < 0 then set ktime to ktime * -1
return ((ktime / 3600) div 1 & " hours, " & ((ktime / 3600) mod 1 * 60) div 1 & " min and " & ((ktime / 3600) mod 1 * 60) mod 1 * 60 div 1 & " sec ") as string -- one line


---> "72 hours, 29 min and 48 sec "


Regards
--
Deivy Petrescu
http://www.dicas.com
_______________________________________________
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.

References: 
 >Date mathematics help please... (From: montana <email@hidden>)

  • Prev by Date: Re: Routines for review: Hex <-> String
  • Next by Date: Re: How to Set Text to Include Quotes (") ?
  • Previous by thread: Date mathematics help please...
  • Next by thread: Re: Date mathematics help please...
  • Index(es):
    • Date
    • Thread