1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/cocoa/private/date.h
3 // Purpose: NSDate-related helpers
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_OSX_COCOA_PRIVATE_DATE_H_
11 #define _WX_OSX_COCOA_PRIVATE_DATE_H_
13 #include "wx/datetime.h"
18 // Functions to convert between NSDate and wxDateTime.
20 // Returns an NSDate corresponding to the given wxDateTime which can be invalid
21 // (in which case nil is returned).
22 inline NSDate
* NSDateFromWX(const wxDateTime
& dt
)
27 // Get the internal representation as a double used by NSDate.
28 double ticks
= dt
.GetValue().ToDouble();
30 // wxDateTime uses milliseconds while NSDate uses (fractional) seconds.
31 return [NSDate dateWithTimeIntervalSince1970
:ticks
/1000.];
35 // Returns wxDateTime corresponding to the given NSDate (which may be nil).
36 inline wxDateTime
NSDateToWX(const NSDate
* d
)
39 return wxDefaultDateTime
;
41 // Reverse everything done above.
43 ll
.Assign([d timeIntervalSince1970
]*1000);
48 } // namespace wxOSXImpl
50 #endif // _WX_OSX_COCOA_PRIVATE_DATE_H_