File indexing completed on 2026-04-09 07:49:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <vector>
0023 #include <iostream>
0024
0025 #include "STime.hh"
0026 #include "s_time.h"
0027 #include "SSys.hh"
0028
0029 #include "OPTICKS_LOG.hh"
0030
0031
0032 void test_EpochSeconds()
0033 {
0034 LOG(info);
0035 int t = s_time::EpochSeconds() ;
0036
0037 std::cout << "s_time::EpochSeconds() " << t << std::endl ;
0038 std::cout << "s_time::Format(\"%c\", t) " << s_time::Format(t, "%c") << std::endl;
0039 std::cout << "s_time::Format() " << s_time::Format() << std::endl;
0040
0041
0042 std::vector<std::string> fmts = { "%c", "%Y", "%m", "%D", "%d", "%H", "%M", "%Y%m%d_%H%M%S" } ;
0043
0044 for(unsigned i=0 ; i < fmts.size() ; i++)
0045 {
0046 std::cout
0047 << "s_time::Format(0,\"" << fmts[i] << "\") "
0048 << s_time::Format(0, fmts[i].c_str())
0049 << std::endl;
0050 }
0051
0052
0053
0054 SSys::run( "date +%s" );
0055 }
0056
0057 void test_mtime()
0058 {
0059 LOG(info);
0060 const char* path = "/tmp/tt.txt" ;
0061 std::string mt = STime::mtime(path);
0062 LOG(info) << " path " << path << " mt " << mt ;
0063 }
0064
0065 void test_Stamp()
0066 {
0067 LOG(info)
0068 << std::endl
0069 << " s_time::Stamp() " << s_time::Stamp()
0070 << std::endl
0071 << " s_time::Format(0,\"%c\") " << s_time::Format(0,"%c")
0072 << std::endl
0073 << " s_time::Now() " << s_time::Now()
0074 << std::endl
0075 ;
0076
0077
0078 }
0079
0080
0081 int main(int argc, char** argv)
0082 {
0083 OPTICKS_LOG(argc, argv);
0084
0085 test_EpochSeconds();
0086 test_mtime();
0087 test_Stamp();
0088
0089 return 0 ;
0090 }