summaryrefslogtreecommitdiff
path: root/indra/newview/lldateutil.cpp
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2011-07-19 15:45:15 -0400
committerOz Linden <oz@lindenlab.com>2011-07-19 15:45:15 -0400
commit20e08f6aa7e260c07bbe367325dea9fb18b7bd4c (patch)
treed26961655587a0a0a666200b009b4d54dcf31af2 /indra/newview/lldateutil.cpp
parent41890cfee81b1883f8f1c80cc07d4fddbffa6e75 (diff)
parentcf8c7701dfd758a9f19e076baad0a9b8d37bbe5f (diff)
merge changes for storm-1221
Diffstat (limited to 'indra/newview/lldateutil.cpp')
-rw-r--r--indra/newview/lldateutil.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/indra/newview/lldateutil.cpp b/indra/newview/lldateutil.cpp
index 18ae6107e7..c7fc45f61e 100644
--- a/indra/newview/lldateutil.cpp
+++ b/indra/newview/lldateutil.cpp
@@ -27,10 +27,16 @@
#include "lldateutil.h"
+#include <boost/date_time/gregorian/gregorian.hpp>
+#include <boost/date_time/posix_time/ptime.hpp>
+
// Linden libraries
#include "lltrans.h"
#include "llui.h"
+using namespace boost::gregorian;
+using namespace boost::posix_time;
+
static S32 DAYS_PER_MONTH_NOLEAP[] =
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
static S32 DAYS_PER_MONTH_LEAP[] =
@@ -186,3 +192,24 @@ std::string LLDateUtil::ageFromDate(const std::string& date_string)
//{
// return ageFromDateISO(date_string, LLDate::now());
//}
+
+S32 LLDateUtil::secondsSinceEpochFromString(const std::string& format, const std::string& str)
+{
+ date_input_facet *facet = new date_input_facet(format);
+
+ std::stringstream ss;
+ ss << str;
+ ss.imbue(std::locale(ss.getloc(), facet));
+
+ date d;
+ ss >> d;
+
+ ptime time_t_date(d);
+ ptime time_t_epoch(date(1970,1,1));
+
+ // We assume that the date defined by str is in UTC, so the difference
+ // is calculated with no time zone corrections.
+ time_duration diff = time_t_date - time_t_epoch;
+
+ return diff.total_seconds();
+}