Commit 33de762c authored by Jonathan Beck's avatar Jonathan Beck

Implement Date object.

parent 6f453688
......@@ -23,6 +23,7 @@
#define DATE_H
#include <plist/Node.h>
#include <ctime>
namespace PList
{
......@@ -34,13 +35,13 @@ class Date : public Node
Date(plist_t node);
Date(Date& d);
Date& operator=(Date& d);
Date(uint64_t i);
Date(timeval t);
virtual ~Date();
Node* Clone();
void SetValue(uint64_t i);
uint64_t GetValue();
void SetValue(timeval t);
timeval GetValue();
};
};
......
......@@ -32,19 +32,21 @@ Date::Date(plist_t node) : Node(node)
{
}
Date::Date(Date& d) : Node(PLIST_DATE)
Date::Date(PList::Date& d) : Node(PLIST_DATE)
{
//TODO
timeval t = d.GetValue();
plist_set_date_val(_node, t.tv_sec, t.tv_usec);
}
Date& Date::operator=(PList::Date& b)
Date& Date::operator=(PList::Date& d)
{
//TODO
plist_free(_node);
_node = plist_copy(d.GetPlist());
}
Date::Date(uint64_t i) : Node(PLIST_DATE)
Date::Date(timeval t) : Node(PLIST_DATE)
{
plist_set_date_val(_node, i, 0);
plist_set_date_val(_node, t.tv_sec, t.tv_usec);
}
Date::~Date()
......@@ -56,16 +58,17 @@ Node* Date::Clone()
return new Date(*this);
}
void Date::SetValue(uint64_t i)
void Date::SetValue(timeval t)
{
plist_set_date_val(_node, i, 0);
plist_set_date_val(_node, t.tv_sec, t.tv_usec);
}
uint64_t Date::GetValue()
timeval Date::GetValue()
{
int32_t i = 0;
plist_get_date_val(_node, &i, &i);
return i;
int32_t tv_sec = 0;
int32_t tv_usec = 0;
plist_get_date_val(_node, &tv_sec, &tv_usec);
return {tv_sec, tv_usec};
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment