Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:22

0001 /*
0002  * Copyright (c) 2019 Opticks Team. All Rights Reserved.
0003  *
0004  * This file is part of Opticks
0005  * (see https://bitbucket.org/simoncblyth/opticks).
0006  *
0007  * Licensed under the Apache License, Version 2.0 (the "License"); 
0008  * you may not use this file except in compliance with the License.  
0009  * You may obtain a copy of the License at
0010  *
0011  *   http://www.apache.org/licenses/LICENSE-2.0
0012  *
0013  * Unless required by applicable law or agreed to in writing, software 
0014  * distributed under the License is distributed on an "AS IS" BASIS, 
0015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0016  * See the License for the specific language governing permissions and 
0017  * limitations under the License.
0018  */
0019 
0020 // TEST=STimeTest om-t
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 }