MACSCRPT Archives

May 2003

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Walter Ian Kaye <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 21 May 2003 16:58:43 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (29 lines)
At 03:03p -0500 05/21/2003, Eric Schult didst inscribe upon an 
electronic papyrus:

>on 5/21/03 1:37 PM, Mark Munro wrote:
>
>  > How about using unix to do that?
>  >
>  > do shell script "date '+%m.%d.%y'"
>
>I'm trying to coerce a string ("05212003") into a date (date "Wednesday, May
>21, 2003 12:00:00 AM"). Can that be done with a variation of the syntax
>above?

Not sure, but it's still easy (and fast) in vanilla AppleScript:

MMDDYYYY_to_Date("05212003")

on MMDDYYYY_to_Date(dstr)
    local dstr, myDate
    set myDate to (current date)
    set year of myDate to text 5 thru 8 of dstr
    set month of myDate to item (text 1 thru 2 of dstr) of ¬
       {January, February, March, April, May, June, ¬
          July, August, September, October, November, December}
    set day of myDate to text 3 thru 4 of dstr
    set time of myDate to 0
    myDate
end MMDDYYYY_to_Date

ATOM RSS1 RSS2