aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/dateTime.cpp29
-rw-r--r--vmime/dateTime.hpp3
2 files changed, 32 insertions, 0 deletions
diff --git a/src/dateTime.cpp b/src/dateTime.cpp
index d0cfcd9e..36aafe2a 100644
--- a/src/dateTime.cpp
+++ b/src/dateTime.cpp
@@ -646,6 +646,35 @@ datetime::datetime(const datetime& d)
}
+datetime::datetime(const time_t t, const int zone)
+{
+#ifdef _REENTRANT
+ struct tm tms;
+
+ if (!gmtime_r(&t, &tms))
+ localtime_r(&t, &tms);
+#else
+ struct tm* gtm = gmtime(&t);
+ struct tm* ltm = localtime(&t);
+
+ struct tm tms;
+
+ if (gtm)
+ tms = *gtm;
+ else if (ltm)
+ tms = *ltm;
+#endif // _REENTRANT
+
+ m_year = tms.tm_year + 1900;
+ m_month = tms.tm_mon + 1;
+ m_day = tms.tm_mday;
+ m_hour = tms.tm_hour;
+ m_minute = tms.tm_min;
+ m_second = tms.tm_sec;
+ m_zone = zone;
+}
+
+
datetime::datetime(const string& date)
{
parse(date);
diff --git a/vmime/dateTime.hpp b/vmime/dateTime.hpp
index 3b0bd252..5f2499ce 100644
--- a/vmime/dateTime.hpp
+++ b/vmime/dateTime.hpp
@@ -28,6 +28,8 @@
#include "vmime/base.hpp"
#include "vmime/component.hpp"
+#include <ctime>
+
namespace vmime
{
@@ -46,6 +48,7 @@ public:
datetime(const int year, const int month, const int day, const int hour, const int minute, const int second, const int zone = GMT);
datetime(const datetime& d);
datetime(const string& date);
+ datetime(const time_t t, const int zone = GMT);
// Destructor
~datetime();