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:
Malcolm Fitzgerald <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Thu, 22 May 2003 10:20:18 +1000
Content-Type:
text/plain
Parts/Attachments:
text/plain (45 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)


This reduces the

-- NOTE: I've altered the date string to YYYYMMDD
-- this is because MMDDYYY is not common outside north america
-- and my settings baulked
-- you'll have to


set theDate to "20030521"
set text item delimiters to "/"
set myDate to date ((get {text 7 thru 8 of theDate, text 5 thru 6 of
theDate, text 1 thru 4 of theDate}) as string)


--
--
Malcolm Fitzgerald                        [log in to unmask]
Database Manager                          http://www.asauthors.org
The Australian Society of Authors         ph: 02 93180877 fax: 02 93180530

ATOM RSS1 RSS2