• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Issues subtracting Unix epoch from date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Issues subtracting Unix epoch from date (From: Nathan Vander Wilt <email@hidden>)

  • Prev by Date: Re: Issues subtracting Unix epoch from date
  • Next by Date: Re: Issues subtracting Unix epoch from date
  • Previous by thread: Re: Issues subtracting Unix epoch from date
  • Next by thread: Re: Issues subtracting Unix epoch from date
  • Index(es):
    • Date
    • Thread