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:
Nigel Garvey <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Thu, 22 May 2003 01:52:39 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (35 lines)
Eric Schult wrote on Wed, 21 May 2003 11:56:25 -0400:

>Another crutch upon which have propped myself up is the dateToStamp and
>stampToDate commands in Tanaka's OSAX, and it's not immediately clear to me
>if
>there's an alternate way in OS X to handle date manipulations like that.

Neither command is in my copy of Tanaka's (2.0). What do they do?

>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.

Do you mean coerce something like "05222003" into a date? On a US
machine, it could be:

  on mmddyyyyToDate(s)
    tell s to get text 1 thru 2 & " " & text 3 thru 4 & " " & text 5 thru
8
    return date result
  end

The converse could be:

  on dateTommyydd(theDate)
    set {day:dd, year:yyyy} to theDate
    copy theDate to b
    set b's month to January
    set mm to (theDate - b + 3944592) div 2629728
    return text 2 thru -1 of ((100000000 + mm * 1000000 + dd * 10000 +
yyyy) as string)
  end dateTommyydd

NG

ATOM RSS1 RSS2