No date for friday? Try this one.
No date for friday? Try this one.
- Subject: No date for friday? Try this one.
- From: Richard 23 <email@hidden>
- Date: Tue, 16 Jan 2001 07:08:12 -0800
This is the latest version of my take on date handling.
Nothing to do with "Russian Hands."
Just it comes up from time to time and I recently updated mine.
feed it a string version of the date and you get back a date.
feed it a date value and you get a string.
If you pass a string which cannot be converted to a date, you
get the current date.
A good way to initialize a property which stores a date would
then be to start out with the value as "".
Something not too unlike this:
-- ---------------------------------------------------------
property Birth_Date : ""
display dialog "Birthdate " default answer
ConvertDate(ConvertDate(Birth_Date))
set Birth_Date to result's text returned
display dialog result & " was on a " & weekday of ConvertDate(result)
-- ---------------------------------------------------------
-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d2
-- ---------------------------------------------------------
ConvertDate("02.27.2002")
ConvertDate(result)
--
---------------------------------------------------------------------------
--
-- Conversions 1.0d12 library Copyright (c) 2000-2001 by Richard 23
--
---------------------------------------------------------------------------
--
-- converts between date and string classes with an adapable delimiter
-- this is US format; just about everyone else in the world puts the day
first
--
---------------------------------------------------------------------------
--
property |t/d| : a reference to AppleScript's text item delimiters
property FF : ASCII character 255
property Date_Delim : "."
--
---------------------------------------------------------------------------
--
on ConvertDate(theDate)
if theDate's class = date then
set {theMonth, theDay, theYear} to theDate's {month, day, year}
set {|t/d|'s contents} to {text 1 thru 3 of (theDate's month as
string)}
set {|t/d|'s contents} to {"", (count words of first text item ==>
of "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") + 1}
set theMonth to text -2 thru -1 of ("0" & result's end)
set theDay to text -2 thru -1 of ("0" & theDay)
return theMonth & Date_Delim & theDay & Date_Delim & theYear
else
repeat with theItem in "./- " & FF
set theChar to theItem's contents
set |t/d|'s contents to result
try
set {theMonth, theDay, theYear} to (theDate's text items)
exit repeat
end try
end repeat
set |t/d|'s contents to ""
if theChar contains FF then
ConvertDate(ConvertDate(current date))
else
set Date_Delim to theChar
date (theMonth & "/" & theDay & "/" & theYear)
end if
end if
return result
end ConvertDate
-- ---------------------------------------------------------
R23