Re: Another question on dates and times
Re: Another question on dates and times
- Subject: Re: Another question on dates and times
- From: "Gary (Lists)" <email@hidden>
- Date: Tue, 04 Dec 2007 23:13:24 -0500
- Thread-topic: Another question on dates and times
"Clint Hoxie" wrote:
> Please tell me what resource I can use to figure this stuff out. I just flat
> don't know where to look, beyond the descriptions in the libraries.
>
> Anyway, I am getting an error which looks to be telling me that a date can't
> be returned as a string.
>
> Here is the code.
>
> --Set variable for default to current date plus one day
> set TomorrowDate to (month of (current date)) + 60 * 60 * 24 & "/" & (day of
> (current date)) + 60 * 60 * 24 & "/" & (year of (current date)) + 60 * 60 *
> 24\
I have an idea what you want to do, but I have no idea why you think that
would do it. ;)
You don't add a day full of seconds to the month or the year just to get
another day. Just add it to the day, while it's still a date, and you'll be
fine.
(In AppleScript, saying "a date" means that the result is an special class
of object. It is a 'date' object.)
current date
-- date "Tuesday, December 4, 2007 10:58:40 PM"
(current date) + (60 * 60 * 24)
-- date "Wednesday, December 5, 2007 10:59:02 PM"
What does that tell us?
It tells us that if you add (implied) seconds to a date, you get a date.
So, add your day of seconds to today to get tomorrow. Since that is still a
'date object', you can then get the month/day/year parts from it as you
would from 'current date'.
-- Here's a working script that achieves your goal, I think:
--
set tod_ to current date
set tom_ to (today_ + (60 * 60 * 24))
-- next line is a single line
set tomString_ to "" & (month of tom_ as integer) & "/" & (day of tom_) &
"/" & (year of tom_)
--> "12/5/2007"
display dialog "blah" default answer tomString_
--
Gary
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden