diff options
author | Jonathan Beck | 2009-10-17 11:10:54 +0200 |
---|---|---|
committer | Jonathan Beck | 2009-10-17 11:10:54 +0200 |
commit | 33de762cf636e3f13f17e02d70de2869664e3f2b (patch) | |
tree | edb92293a1f61d358c76180b9d96b7642f1614a4 /src | |
parent | 6f453688c0b97ea979b2b2b515f4030e69e846fb (diff) | |
download | libplist-33de762cf636e3f13f17e02d70de2869664e3f2b.tar.gz libplist-33de762cf636e3f13f17e02d70de2869664e3f2b.tar.bz2 |
Implement Date object.
Diffstat (limited to 'src')
-rw-r--r-- | src/Date.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/Date.cpp b/src/Date.cpp index 18e1d27..46ef14e 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -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}; } }; |