summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-10-17 11:10:54 +0200
committerGravatar Jonathan Beck2009-10-17 11:10:54 +0200
commit33de762cf636e3f13f17e02d70de2869664e3f2b (patch)
treeedb92293a1f61d358c76180b9d96b7642f1614a4
parent6f453688c0b97ea979b2b2b515f4030e69e846fb (diff)
downloadlibplist-33de762cf636e3f13f17e02d70de2869664e3f2b.tar.gz
libplist-33de762cf636e3f13f17e02d70de2869664e3f2b.tar.bz2
Implement Date object.
-rw-r--r--include/plist/Date.h7
-rw-r--r--src/Date.cpp27
2 files changed, 19 insertions, 15 deletions
diff --git a/include/plist/Date.h b/include/plist/Date.h
index e9645aa..5472657 100644
--- a/include/plist/Date.h
+++ b/include/plist/Date.h
@@ -23,6 +23,7 @@
23#define DATE_H 23#define DATE_H
24 24
25#include <plist/Node.h> 25#include <plist/Node.h>
26#include <ctime>
26 27
27namespace PList 28namespace PList
28{ 29{
@@ -34,13 +35,13 @@ class Date : public Node
34 Date(plist_t node); 35 Date(plist_t node);
35 Date(Date& d); 36 Date(Date& d);
36 Date& operator=(Date& d); 37 Date& operator=(Date& d);
37 Date(uint64_t i); 38 Date(timeval t);
38 virtual ~Date(); 39 virtual ~Date();
39 40
40 Node* Clone(); 41 Node* Clone();
41 42
42 void SetValue(uint64_t i); 43 void SetValue(timeval t);
43 uint64_t GetValue(); 44 timeval GetValue();
44}; 45};
45 46
46}; 47};
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)
32{ 32{
33} 33}
34 34
35Date::Date(Date& d) : Node(PLIST_DATE) 35Date::Date(PList::Date& d) : Node(PLIST_DATE)
36{ 36{
37 //TODO 37 timeval t = d.GetValue();
38 plist_set_date_val(_node, t.tv_sec, t.tv_usec);
38} 39}
39 40
40Date& Date::operator=(PList::Date& b) 41Date& Date::operator=(PList::Date& d)
41{ 42{
42 //TODO 43 plist_free(_node);
44 _node = plist_copy(d.GetPlist());
43} 45}
44 46
45Date::Date(uint64_t i) : Node(PLIST_DATE) 47Date::Date(timeval t) : Node(PLIST_DATE)
46{ 48{
47 plist_set_date_val(_node, i, 0); 49 plist_set_date_val(_node, t.tv_sec, t.tv_usec);
48} 50}
49 51
50Date::~Date() 52Date::~Date()
@@ -56,16 +58,17 @@ Node* Date::Clone()
56 return new Date(*this); 58 return new Date(*this);
57} 59}
58 60
59void Date::SetValue(uint64_t i) 61void Date::SetValue(timeval t)
60{ 62{
61 plist_set_date_val(_node, i, 0); 63 plist_set_date_val(_node, t.tv_sec, t.tv_usec);
62} 64}
63 65
64uint64_t Date::GetValue() 66timeval Date::GetValue()
65{ 67{
66 int32_t i = 0; 68 int32_t tv_sec = 0;
67 plist_get_date_val(_node, &i, &i); 69 int32_t tv_usec = 0;
68 return i; 70 plist_get_date_val(_node, &tv_sec, &tv_usec);
71 return {tv_sec, tv_usec};
69} 72}
70 73
71}; 74};