util.hpp
Go to the documentation of this file.
1 #ifndef STAN_IO_UTIL_HPP
2 #define STAN_IO_UTIL_HPP
3 
4 #include <string>
5 #include <ctime>
6 
7 namespace stan {
8 
9  namespace io {
10 
11  /**
12  * Return the current coordinated universal time (UTC) as a string.
13  *
14  * Output is of the form "Fri Feb 24 21:15:36 2012"
15  *
16  * @return String representation of current UTC.
17  */
19  // FIXME: use std::strftime
20 
21  // original with asctime
22  // std::time_t rawtime = time(0);
23  // std::tm *time = gmtime(&rawtime);
24  // return std::string(asctime(time));
25 
26  // new with strfitime
27  time_t rawtime;
28  std::time(&rawtime);
29 
30  char cbuf[80];
31  std::strftime(cbuf, 80, "%a %b %d %Y %H:%M:%S",
32  std::localtime(&rawtime));
33 
34  return std::string(cbuf);
35  }
36 
37  }
38 }
39 
40 #endif
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::string utc_time_string()
Definition: util.hpp:18