[TxMt] plist and the Ruby date object

Charilaos Skiadas skiadas at hanover.edu
Thu Nov 16 02:21:47 UTC 2006


On Nov 15, 2006, at 8:21 PM, Brett Terpstra wrote:

> So, if 185328000 is a cocoa representation of the current date, how  
> do I get the time added in there?  I honestly tried to figure this  
> out and am stuck again...

Well, Cocoa naturally has the time there as well. It seems the value  
it expects is the number of seconds since January 1st, 2001, GMT.
The surprising thing is that it instead returns a string  
representation of the date. Perhaps there is a way to get that answer  
is seconds as well, but I haven't been able to, hence all the weird  
regexps that follow.

> I kind of understand this part:
>
> def to_cocoa_date(date)
>   ((date - Date.new(2001, 1, 1)+1)* 3600 * 24).to_i
> end
>
> date = Date.today
>
> But I don't know what formula to run on Time.now to get the same  
> result.

Probably this should do it:

Time.new-Time.gm(2001, 1, 1, 0, 0, 0)

might need a bit of experimenting.

Haris





More information about the textmate mailing list