From 81bd1e1fb6cb2a74c4e372410fb419cfc94991e0 Mon Sep 17 00:00:00 2001 From: ipkn Date: Fri, 2 May 2014 01:17:49 -0400 Subject: caching datetime string for Date header --- datetime.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'datetime.h') diff --git a/datetime.h b/datetime.h index 24fd3c4..0a47379 100644 --- a/datetime.h +++ b/datetime.h @@ -23,12 +23,12 @@ namespace crow // return datetime string std::string str() { + static const std::locale locale_(std::locale::classic(), new boost::local_time::local_time_facet("%a, %d %b %Y %H:%M:%S GMT") ); std::string result; - boost::local_time::local_time_facet* lf(new boost::local_time::local_time_facet("%a, %d %b %Y %H:%M:%S GMT")); try { std::stringstream ss; - ss.imbue(std::locale(ss.getloc(), lf)); + ss.imbue(locale_); ss << m_dt; result = ss.str(); } @@ -59,9 +59,9 @@ namespace crow // parse datetime string void parse(const std::string& dt) { - boost::local_time::local_time_input_facet* lif(new boost::local_time::local_time_input_facet("%a, %d %b %Y %H:%M:%S GMT")); + static const std::locale locale_(std::locale::classic(), new boost::local_time::local_time_facet("%a, %d %b %Y %H:%M:%S GMT") ); std::stringstream ss(dt); - ss.imbue(std::locale(std::locale::classic(), lif)); + ss.imbue(locale_); ss >> m_dt; } -- cgit v1.2.3-54-g00ecf