So it seems that NSDates can’t be coerced to AS dates, or even to AS strings easily. You can get the description and parse the resulting string, but that looks fragile to me.
One of the differences between NSDate and AS dates is that AS dates assume the user’s calendar, whereas getting the details out of an NSDate involves specifying the calendar. In fact, it’s a multi-part process.
You can get the calendar in use by calling NSCalendar’s class method currentCalendar:. With that instance of a calendar, you can call the calendar’s components:fromDate: method. This returns an NSDateComponents object, which has methods for returning the year, month, etc.
So let’s assume a date from a date picker:
set theDate to my picker's dateValue()
set theCal to current application's class "NSCalendar"'s currentCalendar()
set theComponents to theCal's components_fromDate_(254, theDate)
The 254 is a mask for which components we want the result to contain; 254 means year, month, day, hour, minute, second, but there are others.
The NSDateComponents class has methods for extracting the components individually, so:
set theYear to theComponents's |year|()
set theMonth to theComponents's |month|()
set theDay to theComponents's |day|()
set theHour to theComponents's hour()
set theMinute to theComponents's minute()
set theSecond to theComponents's |second|()
Now you need to make an AS date, and set the various components:
set theDate to current date
set day of theDate to 1 -- important
set seconds of theDate to theSecond
set year of theDate to theYear
set month of theDate to theMonth
set day of theDate to theDay
set hours of theDate to theHour
set minutes of theDate to theMinute
log (theDate as text)
It’s a fair bit of code to do what I suspect should happen automatically, but on my MacBook it takes all of 0.003 seconds, so there’s no real performance hit. If you need to use it often, you could easily wrap it up in a handler.
Edited: I’ve inserted the line “set day of theDate to 1” to avoid problems when the day of the current date exceeds the number of days in the new date.