Hey group,
I am new to OS X and applescript. I have been programming for many
years, though applescript seems a little weird to me because of how
verbose and natural language like it is.
Anyway, I am trying to do something simple, I need to get the current
date in the format: YYYY:MM:DD.
The following code gives me the name of the month instead of the number
for the month:
set theMonth to month of theDate
So I created a simple function/handler, though I don't know what the
heck is going on because it does not work. I get an error that
theMonth is not defined.
set theDate to current date
set theYear to year of theDate
set theMonth to convertMonth(month of theDate)
set theDay to day of theDate
set dateStr to theYear & ":" & theMonth & ":" & theDay
display dialog "Enter image date (YYYY:MM:DD):" default answer dateStr as
text
set theDate to text returned of result
display dialog theDate
on convertMonth(theMonth)
if theMonth = "January" or theMonth = "Jan" then
return "01"
else if theMonth = "February" or theMonth = "Feb" then
return "02"
else if theMonth = "March" or theMonth = "Mar" then
return "03"
else if theMonth = "April" or theMonth = "Apr" then
return "04"
else if theMonth = "May" or theMonth = "May" then
return "05"
else if theMonth = "June" or theMonth = "Jun" then
return "06"
else if theMonth = "July" or theMonth = "Jul" then
return "07"
else if theMonth = "August" or theMonth = "Aug" then
return "08"
else if theMonth = "September" or theMonth = "Sep" then
return "09"
else if theMonth = "October" or theMonth = "Oct" then
return "10"
else if theMonth = "November" or theMonth = "Nov" then
return "11"
else if theMonth = "December" or theMonth = "Dec" then
return "12"
end if
end convertMonth
Thanks for any help,
Jim
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access


|