diff options
Diffstat (limited to 'Swiften/Base/DateTime.cpp')
| -rw-r--r-- | Swiften/Base/DateTime.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Swiften/Base/DateTime.cpp b/Swiften/Base/DateTime.cpp index 4f55a8e..d19e9c7 100644 --- a/Swiften/Base/DateTime.cpp +++ b/Swiften/Base/DateTime.cpp | |||
| @@ -11,10 +11,11 @@ | |||
| 11 | #include <boost/date_time/local_time/local_time.hpp> | 11 | #include <boost/date_time/local_time/local_time.hpp> |
| 12 | #include <boost/date_time/posix_time/posix_time.hpp> | 12 | #include <boost/date_time/posix_time/posix_time.hpp> |
| 13 | #include <boost/date_time/c_local_time_adjustor.hpp> | 13 | #include <boost/date_time/c_local_time_adjustor.hpp> |
| 14 | 14 | ||
| 15 | #include <Swiften/Base/String.h> | 15 | #include <Swiften/Base/String.h> |
| 16 | #include <Swiften/Base/Log.h> | ||
| 16 | 17 | ||
| 17 | namespace Swift { | 18 | namespace Swift { |
| 18 | 19 | ||
| 19 | boost::posix_time::ptime stringToDateTime(const std::string& string) { | 20 | boost::posix_time::ptime stringToDateTime(const std::string& string) { |
| 20 | static std::locale locale(std::locale::classic(), new boost::local_time::local_time_input_facet("%Y-%m-%d %H:%M:%S%F%ZP")); | 21 | static std::locale locale(std::locale::classic(), new boost::local_time::local_time_input_facet("%Y-%m-%d %H:%M:%S%F%ZP")); |
| @@ -31,9 +32,16 @@ std::string dateTimeToString(const boost::posix_time::ptime& time) { | |||
| 31 | stampString += "Z"; | 32 | stampString += "Z"; |
| 32 | return stampString; | 33 | return stampString; |
| 33 | } | 34 | } |
| 34 | 35 | ||
| 35 | std::string dateTimeToLocalString(const boost::posix_time::ptime& time) { | 36 | std::string dateTimeToLocalString(const boost::posix_time::ptime& time) { |
| 36 | return boost::posix_time::to_simple_string(boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(time)); | 37 | std::string localString; |
| 38 | try { | ||
| 39 | localString = boost::posix_time::to_simple_string(boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(time)); | ||
| 40 | } | ||
| 41 | catch(std::out_of_range& exception) { | ||
| 42 | SWIFT_LOG(debug) << exception.what() << std::endl; | ||
| 43 | } | ||
| 44 | return localString; | ||
| 37 | } | 45 | } |
| 38 | 46 | ||
| 39 | } | 47 | } |
Swift