summaryrefslogtreecommitdiffstats
path: root/src/Date.cpp
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2025-05-13 18:34:32 +0200
committerGravatar Nikias Bassen2025-05-13 18:34:32 +0200
commitcb76e4da84c61609c13e84c922f14a27b8348a36 (patch)
tree6f0057efd11780ec38da6e8b686726f51bd10f30 /src/Date.cpp
parentd7fe479707af57aeedf7e41c08e7fb698cd2e2a3 (diff)
downloadlibplist-cb76e4da84c61609c13e84c922f14a27b8348a36.tar.gz
libplist-cb76e4da84c61609c13e84c922f14a27b8348a36.tar.bz2
Add plist_new_unix_date, plist_get_unix_date_val, plist_set_unix_date_val functions
These functions work with int64_t values representing a UNIX timestamp instead of using the 'MAC epoch'. They should be used instead of plist_new_date, plist_get_date_val, and plist_set_date_val, which are now marked deprecated and might be removed in a future version of libplist.
Diffstat (limited to 'src/Date.cpp')
-rw-r--r--src/Date.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/Date.cpp b/src/Date.cpp
index 8b8e650..cbfa123 100644
--- a/src/Date.cpp
+++ b/src/Date.cpp
@@ -34,8 +34,8 @@ Date::Date(plist_t node, Node* parent) : Node(node, parent)
34 34
35Date::Date(const PList::Date& d) : Node(PLIST_DATE) 35Date::Date(const PList::Date& d) : Node(PLIST_DATE)
36{ 36{
37 timeval t = d.GetValue(); 37 int64_t t = d.GetValue();
38 plist_set_date_val(_node, t.tv_sec, t.tv_usec); 38 plist_set_unix_date_val(_node, t);
39} 39}
40 40
41Date& Date::operator=(const PList::Date& d) 41Date& Date::operator=(const PList::Date& d)
@@ -45,9 +45,9 @@ Date& Date::operator=(const PList::Date& d)
45 return *this; 45 return *this;
46} 46}
47 47
48Date::Date(timeval t) : Node(PLIST_DATE) 48Date::Date(int64_t t) : Node(PLIST_DATE)
49{ 49{
50 plist_set_date_val(_node, t.tv_sec, t.tv_usec); 50 plist_set_unix_date_val(_node, t);
51} 51}
52 52
53Date::~Date() 53Date::~Date()
@@ -59,18 +59,16 @@ Node* Date::Clone() const
59 return new Date(*this); 59 return new Date(*this);
60} 60}
61 61
62void Date::SetValue(timeval t) 62void Date::SetValue(int64_t t)
63{ 63{
64 plist_set_date_val(_node, t.tv_sec, t.tv_usec); 64 plist_set_unix_date_val(_node, t);
65} 65}
66 66
67timeval Date::GetValue() const 67int64_t Date::GetValue() const
68{ 68{
69 int32_t tv_sec = 0; 69 int64_t sec = 0;
70 int32_t tv_usec = 0; 70 plist_get_unix_date_val(_node, &sec);
71 plist_get_date_val(_node, &tv_sec, &tv_usec); 71 return sec;
72 timeval t = {tv_sec, tv_usec};
73 return t;
74} 72}
75 73
76} // namespace PList 74} // namespace PList