Re: Issues subtracting Unix epoch from date
Re: Issues subtracting Unix epoch from date
- Subject: Re: Issues subtracting Unix epoch from date
- From: Shane Stanley <email@hidden>
- Date: Sun, 21 Feb 2010 11:15:16 +1100
- Thread-topic: Issues subtracting Unix epoch from date
On 21/2/10 10:06 AM, "Nathan Vander Wilt" <email@hidden> wrote:
> I am considering writing a faceless scriptable Cocoa app to do a more
> efficient conversion
FWIW, this is what I use in ASObjC to convert an AS date to an NSDate in the
current time zone:
-- assume theASDate contains an AS date
-- get components of date
set theYear to year of theASDate
set theMonth to month of theASDate as integer
set theDay to day of theASDate
set theHour to hours of theASDate
set theMinute to minutes of theASDate
set theSecond to seconds of theASDate
-- make new instance of NSDateComponents and set its properties
set theComponents to current application's NSDateComponents's alloc()'s
init()
tell theComponents
setYear_(theYear)
setMonth_(theMonth)
setDay_(theDay)
setHour_(theHour)
setMinute_(theMinute)
setSecond_(theSecond)
end tell
-- tell NSCalendar to build a date from the provided components
set theNSDate to current application's NSCalendar's currentCalendar()'s
dateFromComponents_(theComponents)
log theNSDate
The reverse is along the same lines.
--
Shane Stanley <email@hidden>
AppleScript Pro, April 2010, Florida <http://www.applescriptpro.com>
_______________________________________________
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