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:
Eric Schult <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 21 May 2003 14:40:56 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (26 lines)
on 5/21/03 1:37 PM, Mark Lively wrote:

>> For example, if I want to coerce a a string (i.e. "mmddyyyy") into a
>> date, I'm completely beholden to Tanaka's to do that.
>>
>> Any clues?
>>
> It can be done in vanilla applescript.  It won't be fast.
>
> on mm_to_date(aDate)
> if month of aDate = January then return "01"
> if month of aDate = February then return "02" ... <snip>

WOW! That's a mouthful of code! You're a lifesaver. But now I'm really
starting to mourn the loss of Tanaka's. The stampToDate command can handle a
string to date coercion as simply as this:

set dateString to "05212003"
set myDay to ((characters 3 thru 4 of dateString) as string)
set myMonth to ((characters 1 thru 2 of dateString) as string)
set myYear to ((characters 7 thru 8 of dateString) as string)
set myTime to "000000"
set myDate to StampToDate (myYear & myMonth & myDay & myTime)

- WES

ATOM RSS1 RSS2