aboutsummaryrefslogtreecommitdiffstats
path: root/datetime.h
diff options
context:
space:
mode:
authoripkn <ipknhama@gmail.com>2014-05-02 01:17:49 -0400
committeripkn <ipknhama@gmail.com>2014-05-02 01:17:49 -0400
commit81bd1e1fb6cb2a74c4e372410fb419cfc94991e0 (patch)
treefecebb2f7887cf73f6e6aa1d5ce9ee1d7d3cc57c /datetime.h
parentf8893eb138eae88f35ba752221a02b318d275364 (diff)
downloadcrow-81bd1e1fb6cb2a74c4e372410fb419cfc94991e0.tar.gz
crow-81bd1e1fb6cb2a74c4e372410fb419cfc94991e0.zip
caching datetime string for Date header
Diffstat (limited to 'datetime.h')
-rw-r--r--datetime.h8
1 files changed, 4 insertions, 4 deletions
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;
}