#ifndef _H_CSSMDATES
#define _H_CSSMDATES
#include <security_utilities/utilities.h>
#include <security_cdsa_utilities/cssmdata.h>
#include <CoreFoundation/CFDate.h>
namespace Security {
class CssmDate : public PodWrapper<CssmDate, CSSM_DATE> {
public:
CssmDate() { }
CssmDate(const char *y, const char *m, const char *d);
CssmDate(int y, int m, int d);
const char *years() const { return reinterpret_cast<const char *>(Year); }
const char *months() const { return reinterpret_cast<const char *>(Month); }
const char *days() const { return reinterpret_cast<const char *>(Day); }
char *years() { return reinterpret_cast<char *>(Year); }
char *months() { return reinterpret_cast<char *>(Month); }
char *days() { return reinterpret_cast<char *>(Day); }
int year() const;
int month() const;
int day() const;
private:
static void assign(char *dest, int width, const char *src);
};
inline bool operator == (const CSSM_DATE &d1, const CSSM_DATE &d2)
{ return !memcmp(&d1, &d2, sizeof(d1)); }
inline bool operator != (const CSSM_DATE &d1, const CSSM_DATE &d2)
{ return !memcmp(&d1, &d2, sizeof(d1)); }
class CssmUniformDate {
public:
CssmUniformDate() { }
CssmUniformDate(CFDateRef ref);
operator CFDateRef() const;
CssmUniformDate(CFAbsoluteTime ct) : mTime(ct) { }
operator CFAbsoluteTime() const { return mTime; }
CssmUniformDate(const CssmDate &src);
operator CssmDate () const;
CssmUniformDate(const CSSM_DATA &src);
void convertTo(CssmOwnedData &data) const;
CssmUniformDate(const char *src);
void convertTo(char *dest, size_t length) const;
bool operator < (const CssmUniformDate &other) const { return mTime < other.mTime; }
bool operator == (const CssmUniformDate &other) const { return mTime == other.mTime; }
bool operator > (const CssmUniformDate &other) const { return mTime > other.mTime; }
bool operator <= (const CssmUniformDate &other) const { return mTime <= other.mTime; }
bool operator >= (const CssmUniformDate &other) const { return mTime >= other.mTime; }
bool operator != (const CssmUniformDate &other) const { return mTime != other.mTime; }
private:
void setFromString(const char *src, const char *format, size_t fieldLength);
private:
CFAbsoluteTime mTime;
};
}
#endif //_H_CSSMDATES