• 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: Stop a script at a certain time?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stop a script at a certain time?


  • Subject: Re: Stop a script at a certain time?
  • From: has <email@hidden>
  • Date: Mon, 20 Dec 2004 18:33:03 +0000

Aaron Rosenblum wrote:

Is there an easy way to convert from the time in total seconds (as returned by "time of (current date)") to a user readable "military" or "AM/PM" time string and back in AS? I have been looking around and can't seem to find any such functions, but I thought I'd ask.

AppleMods' Date library <http://applemods.sourceforge.net/mods/Data/Date.php> [1] generates nice parser and formatter objects for converting strings to dates and vice-versa:


property _Date : (run application "LoaderServer")'s makeLoader()'s loadLib("Date")

    set formatterObj to _Date's makeFormatter("HHMM")
    set parserObj to _Date's makeParser("HHMM")

    set s to "0600"
    log time of parserObj's parseText(s)'s item 1 --> 21600

    set t to 21600
    set d to current date
    set d's time to t
    log formatterObj's formatDate(d) --> "0600"


Parser and formatter objects are reusable and you can generate as many as you like. For 12-hour AM/PM times, create a parser/formatter using "h:MM TT" as the format string, e.g.:


    _Date's makeFormatter("h:MM TT")'s currentDate() --> "6:30 PM"

There's a full list of supported format codes in the manual.

HTH

has

[1] If you've not used AppleMods' libraries before, you'll need to download and install AppleMods' Loader system first. Go to <http://applemods.sourceforge.net/getstarted.html> to get started. Install Loader and add the Date library to the ASLibraries folder, then use the LoaderWizard applet to generate the required library-loading code to paste at the top of your script.
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
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
  • Prev by Date: Re: Character encoding to HTML entities - Swedish oddity
  • Next by Date: Satimage: non-greedy regexp matching?
  • Previous by thread: Re: Stop a script at a certain time?
  • Next by thread: Re: Stop a script at a certain time?
  • Index(es):
    • Date
    • Thread