- Code: Select all
set value of variable "pennwood_date" to (items 1 thru -7 of (date string of (current date)) as text) as string
# The text on the next line came from Niel
# (items 1 thru -7 of (date string of (current date)) as text) as string
# at https://discussions.apple.com/message/31262688?ac_cid=op123456#31262688
set value of variable "pennwood_day" to (weekday of (current date)) as text
set value of variable "pennwood_month" to (month of (current date)) as text
# The following lines were obtained from an Apple discussion group
# https://discussions.apple.com/message/31262688?ac_cid=op123456#31262688
set theDate to (current date)
set isoDate to theDate as «class isot» as string -- get current iso date/time
log isoDate
set value of variable "pennwood_time" to isoTimeTo12Hour(isoDate)
isoTimeTo12Hour(isoDate)
on isoTimeTo12Hour(isoDateString) -- convert 24-hour time to AM/PM
set meridiem to " AM"
set theHour to text 12 thru 13 of isoDateString as number
if theHour = 12 then set meridiem to " PM"
if theHour = 0 then set theHour to 12
if theHour > 12 then set {theHour, meridiem} to {theHour - 12, " PM"}
return "" & theHour & text 14 thru 16 of isoDateString & meridiem
end isoTimeTo12Hour
# end of script from Apple discussion group
set spring to {April, May}
set summer to {June, July, August}
set fall to {September, October, November}
set winter to {December, January, February, March}
if month of (current date) is in spring then
set value of variable "pennwood_season" to "Spring"
else if month of (current date) is in summer then
set value of variable "pennwood_season" to "Summer"
else if month of (current date) is in fall then
set value of variable "pennwood_season" to "Fall"
else if month of (current date) is in winter then
set value of variable "pennwood_season" to "Winter"
end if