1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/cocoa/private/date.h
3 // Purpose: NSDate-related helpers
4 // Author: Vadim Zeitlin
6 // RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_OSX_COCOA_PRIVATE_DATE_H_
12 #define _WX_OSX_COCOA_PRIVATE_DATE_H_
14 #include "wx/datetime.h"
19 // Functions to convert between NSDate and wxDateTime.
21 // Returns an NSDate corresponding to the given wxDateTime which can be invalid
22 // (in which case nil is returned).
23 inline NSDate
* NSDateFromWX(const wxDateTime
& dt
)
28 // Get the internal representation as a double used by NSDate.
29 double ticks
= dt
.GetValue().ToDouble();
31 // wxDateTime uses milliseconds while NSDate uses (fractional) seconds.
32 return [NSDate dateWithTimeIntervalSince1970
:ticks
/1000.];
36 // Returns wxDateTime corresponding to the given NSDate (which may be nil).
37 inline wxDateTime
NSDateToWX(const NSDate
* d
)
40 return wxDefaultDateTime
;
42 // Reverse everything done above.
44 ll
.Assign([d timeIntervalSince1970
]*1000);
49 } // namespace wxOSXImpl
51 #endif // _WX_OSX_COCOA_PRIVATE_DATE_H_