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:
David Livesay <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 21 May 2003 20:34:35 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (68 lines)
My $.02:

to dateParse(d)
        return date (text 1 thru 2 of d & "/" & text 3 thru 4 of d & "/" &
text 5 thru 8 of d)
end dateParse

dateParse("05212003")

--> date "Wednesday, May 21, 2003 12:00:00 AM"

On Wednesday, May 21, 2003, at 04:45  PM, Ben Waldie wrote:

> WES,
>
> On Wednesday, May 21, 2003, at 03:40 PM, Eric Schult wrote:
>
>> 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)
>
> If you know where the day, month, and year will be, you can reformat
> the date to a short date string using a delimiter to separate the
> items.  Then, you can coerce the short date string to a date.  I.e. -
>
> set theDelimiter to "."
> -- OR
> set theDelimiter to "-"
> -- OR
> set theDelimiter to "/"
>
> set theDate to "05212003"
> set theMonth to text 1 thru 2 of theDate
> set theDay to text 3 thru 4 of theDate
> set theYear to text 5 thru 8 of theDate
> set theDate to theMonth & theDelimiter & theDay & theDelimiter &
> theYear
>
> date theDate
> --> RETURNS - date "Wednesday, May 21, 2003 12:00:00 AM"
>
> Thanks,
>
> - Ben
>
> Benjamin S. Waldie
> Automated Workflows, LLC
> =============================================
> AppleScript and Workflow Automation
> Consulting - <http://www.automatedworkflows.com>
> AppleScript Info - <http://www.applescriptguru.com>
> AppleScript Training - <http://www.applescripttraining.com>
> =============================================
>
--
Dave
====
"It is better to have a permanent income than to be fascinating."
--Oscar Wilde

ATOM RSS1 RSS2