BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
SysUtils.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Base/Util/SysUtils.cpp
6 //! @brief Implements various stuff in namespace Utils.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #include "Base/Util/SysUtils.h"
16 #include <chrono>
17 #include <iomanip>
18 #include <iostream>
19 #include <sstream>
20 #include <stdexcept>
21 
23 {
24  using clock = std::chrono::system_clock;
25 
26  std::stringstream output;
27  std::time_t current_time = clock::to_time_t(clock::now());
28  output << std::put_time(std::gmtime(&current_time), "%Y-%b-%d %T");
29  return output.str();
30 }
31 
32 std::string BaseUtils::System::getenv(const std::string& name)
33 {
34  if (char* c = std::getenv(name.c_str()))
35  return c;
36  return "";
37 }
Defines various stuff in namespace Utils.
std::string getenv(const std::string &name)
Returns environment variable.
Definition: SysUtils.cpp:32
std::string getCurrentDateAndTime()
Definition: SysUtils.cpp:22