MACSCRPT Archives

February 2007

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:
"J.L.Slangen" <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Mon, 26 Feb 2007 17:51:26 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (64 lines)
Hello,

On my computer the result of (current date) is (in dutch):
date "maandag 26 februari 2007 16:13:43".
So the date format is dd/mm/yyyy
The statement:
set d1 to "26/02/2007"
sets the value of d1 to
date "maandag 26 februari 2007 00:00:00"
The value of user_date at the end of the following mini-program is:
"26/02/2007" (Unicode (UTF-16) text)

set dialog_text to "Enter date "
set date_dialog to display dialog dialog_text default answer "dd/mm/ 
yyyy"
set user_date to text returned of date_dialog

The value of d2 in
set d2 to date user_date
becomes: date "maandag 26 februari 2007 00:00:00"

Put the mini program in a Finder tell-block and enter "02/03/2007":
tell application "Finder"
	set dialog_text to "Enter date "
	set date_dialog to display dialog dialog_text default answer "dd/mm/ 
yyyy"
	set user_date2 to text returned of date_dialog
	set d3 to date user_date2
	end tell
and you will get an error: Can't make "02/03/2007" into type date.
(The class of user_date2 is Unicode text)

Now leave out "set d3 to date user_date2", and put it after the tell- 
block.

tell application "Finder"
	
	set dialog_text to "Enter date "
	set date_dialog to display dialog dialog_text default answer "dd/mm/ 
yyyy"
	set user_date2 to text returned of date_dialog
end tell
set d3 to date user_date2

and the value of d3 is the date:
date "vrijdag 2 maart 2007 00:00:00"

The problem is that the Finder dictionary tells me that "date  
string" ( type string) can get me the date portion of a date-time  
value as text.
Why then is the following script not working?

tell application "Finder"
	set dialog_text to "Enter date "
	set date_dialog to display dialog dialog_text default answer "dd/mm/ 
yyyy"
	set user_date2 to text returned of date_dialog as string
	set d3 to date string of user_date2
end tell

I appreciate any enlightenment

J.L. Slangen

ATOM RSS1 RSS2