From 39a8748ac6d2ed951b3771d3225a8e74b19ce25b Mon Sep 17 00:00:00 2001 From: Nick Draper <nick.draper@stfc.ac.uk> Date: Thu, 31 Jan 2008 11:02:57 +0000 Subject: [PATCH] Closes #56 Improved output date format to 2007-Dec-31 12:10:20 --- Code/Mantid/DataHandling/test/LoadLogTest.h | 14 +++++----- Code/Mantid/DataHandling/test/runTests.bat | 2 +- .../inc/MantidKernel/TimeSeriesProperty.h | 27 +++++++++---------- Code/Mantid/Kernel/test/ConfigServiceTest.h | 5 +++- .../Kernel/test/TimeSeriesPropertyTest.h | 6 ++--- Code/Mantid/Kernel/test/runTests.bat | 2 +- Code/Mantid/Main/Main.cpp | 2 +- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Code/Mantid/DataHandling/test/LoadLogTest.h b/Code/Mantid/DataHandling/test/LoadLogTest.h index e867c22d573..39de51d75ad 100644 --- a/Code/Mantid/DataHandling/test/LoadLogTest.h +++ b/Code/Mantid/DataHandling/test/LoadLogTest.h @@ -78,7 +78,7 @@ public: std::string timeSeriesString = l_timeSeries->value(); // test that log file read in ok - TS_ASSERT_EQUALS( timeSeriesString.substr(0,30), "Fri Nov 16 13:25:48 2007 END" ); + TS_ASSERT_EQUALS( timeSeriesString.substr(0,26), "2007-Nov-16 13:25:48 END" ); } @@ -124,27 +124,27 @@ public: Property *l_property = sample.getLogData( std::string("../../../../Test/Data/HRP37125_ICPevent.txt") ); TimeSeriesProperty<std::string> *l_timeSeriesString = dynamic_cast<TimeSeriesProperty<std::string>*>(l_property); std::string timeSeriesString = l_timeSeriesString->value(); - TS_ASSERT_EQUALS( timeSeriesString.substr(0,32), "Tue Nov 13 15:19:13 2007 BEGIN" ); + TS_ASSERT_EQUALS( timeSeriesString.substr(0,28), "2007-Nov-13 15:19:13 BEGIN" ); l_property = sample.getLogData( std::string("../../../../Test/Data/HRP37125_cphs_6.txt") ); TimeSeriesProperty<double> *l_timeSeriesDouble = dynamic_cast<TimeSeriesProperty<double>*>(l_property); timeSeriesString = l_timeSeriesDouble->value(); - TS_ASSERT_EQUALS( timeSeriesString.substr(0,27), "Tue Nov 13 15:16:20 2007 0" ); + TS_ASSERT_EQUALS( timeSeriesString.substr(0,23), "2007-Nov-13 15:16:20 0" ); l_property = sample.getLogData( std::string("../../../../Test/Data/HRP37125_PROP3.txt") ); l_timeSeriesDouble = dynamic_cast<TimeSeriesProperty<double>*>(l_property); timeSeriesString = l_timeSeriesDouble->value(); - TS_ASSERT_EQUALS( timeSeriesString.substr(0,27), "Tue Nov 13 15:16:20 2007 0" ); + TS_ASSERT_EQUALS( timeSeriesString.substr(0,23), "2007-Nov-13 15:16:20 0" ); l_property = sample.getLogData( std::string("../../../../Test/Data/HRP37125_SE_He_Level.txt") ); l_timeSeriesDouble = dynamic_cast<TimeSeriesProperty<double>*>(l_property); timeSeriesString = l_timeSeriesDouble->value(); - TS_ASSERT_EQUALS( timeSeriesString.substr(0,28), "Tue Nov 13 15:17:08 2007 -1" ); + TS_ASSERT_EQUALS( timeSeriesString.substr(0,24), "2007-Nov-13 15:17:08 -1" ); l_property = sample.getLogData( std::string("../../../../Test/Data/HRP37125_TEMP1.txt") ); l_timeSeriesDouble = dynamic_cast<TimeSeriesProperty<double>*>(l_property); timeSeriesString = l_timeSeriesDouble->value(); - TS_ASSERT_EQUALS( timeSeriesString.substr(0,27), "Tue Nov 13 15:16:20 2007 0" ); + TS_ASSERT_EQUALS( timeSeriesString.substr(0,23), "2007-Nov-13 15:16:20 0" ); } @@ -192,7 +192,7 @@ public: Property *l_property = sample.getLogData( std::string("../../../../Test/Data/HRP37129_ICPevent.txt") ); TimeSeriesProperty<std::string> *l_timeSeriesString = dynamic_cast<TimeSeriesProperty<std::string>*>(l_property); std::string timeSeriesString = l_timeSeriesString->value(); - TS_ASSERT_EQUALS( timeSeriesString.substr(0,30), "Fri Nov 16 13:25:48 2007 END" ); + TS_ASSERT_EQUALS( timeSeriesString.substr(0,26), "2007-Nov-16 13:25:48 END" ); } diff --git a/Code/Mantid/DataHandling/test/runTests.bat b/Code/Mantid/DataHandling/test/runTests.bat index 8208a772e81..acf5bb9c517 100644 --- a/Code/Mantid/DataHandling/test/runTests.bat +++ b/Code/Mantid/DataHandling/test/runTests.bat @@ -21,7 +21,7 @@ GOTO COMPILE :COMPILE echo "Compiling the test executable..." -cl runner.cpp /I "..\..\..\Third_Party\include" /I "..\.." /I "..\inc" /I "../../Kernel/inc" /I "../../API/inc" /I "../../Geometry/inc" /I "../../DataObjects/inc" /wd4275 /EHsc /MDd /W3 /nologo /c /ZI /TP +cl runner.cpp /I "..\..\..\Third_Party\include" /I "..\.." /I "..\inc" /I "../../Kernel/inc" /I "../../API/inc" /I "../../Geometry/inc" /I "../../DataObjects/inc" /D_CRT_SECURE_NO_DEPRECATE /wd4275 /EHsc /MDd /W3 /nologo /c /ZI /TP link /OUT:"runner.exe" /NOLOGO /LIBPATH:"../../Debug" /LIBPATH:"../../../Third_Party/lib/win32" /DEBUG /PDB:".\runner.pdb" Mantidkernel.lib Mantiddataobjects.lib Mantiddatahandling.lib Mantidgeometry.lib MantidAPI.lib runner.obj diff --git a/Code/Mantid/Kernel/inc/MantidKernel/TimeSeriesProperty.h b/Code/Mantid/Kernel/inc/MantidKernel/TimeSeriesProperty.h index 845671e0bb8..86f03f9b913 100644 --- a/Code/Mantid/Kernel/inc/MantidKernel/TimeSeriesProperty.h +++ b/Code/Mantid/Kernel/inc/MantidKernel/TimeSeriesProperty.h @@ -74,12 +74,9 @@ public: while ( p != m_propertySeries.end() ) { - // asctime has the annoying feature of appending a '\n' - // hence the reason of first reading in the data-time into str - // before printing out this string minus the '\n' - - std::string str(asctime(localtime(&(p->first)))); - ins << str.substr(0,str.size()-1) << " " << p->second << std::endl; + char buffer [25]; + strftime (buffer,25,"%Y-%b-%d %H:%M:%S",localtime(&(p->first))); + ins << buffer << " " << p->second << std::endl; p++; } @@ -115,22 +112,22 @@ private: /// Create time_t instance from a ISO 8601 yyyy-mm-ddThh:mm:ss input string std::time_t createTime_t_FromString(const std::string &str) { - struct std::tm * time_since_1990; + struct std::tm * time_since_1900; // create tm struct time_t rawtime; time( &rawtime ); - time_since_1990 = localtime( &rawtime ); + time_since_1900 = localtime( &rawtime ); - time_since_1990->tm_year = atoi(str.substr(0,4).c_str()) - 1900; - time_since_1990->tm_mon = atoi(str.substr(5,2).c_str()) - 1; - time_since_1990->tm_mday = atoi(str.substr(8,2).c_str()); - time_since_1990->tm_hour = atoi(str.substr(11,2).c_str()); - time_since_1990->tm_min = atoi(str.substr(14,2).c_str()); - time_since_1990->tm_sec = atoi(str.substr(17,2).c_str()); + time_since_1900->tm_year = atoi(str.substr(0,4).c_str()) - 1900; + time_since_1900->tm_mon = atoi(str.substr(5,2).c_str()) - 1; + time_since_1900->tm_mday = atoi(str.substr(8,2).c_str()); + time_since_1900->tm_hour = atoi(str.substr(11,2).c_str()); + time_since_1900->tm_min = atoi(str.substr(14,2).c_str()); + time_since_1900->tm_sec = atoi(str.substr(17,2).c_str()); - return mktime(time_since_1990); + return mktime(time_since_1900); } /// static reference to the logger class diff --git a/Code/Mantid/Kernel/test/ConfigServiceTest.h b/Code/Mantid/Kernel/test/ConfigServiceTest.h index df56b2922a4..31556bf230c 100644 --- a/Code/Mantid/Kernel/test/ConfigServiceTest.h +++ b/Code/Mantid/Kernel/test/ConfigServiceTest.h @@ -86,7 +86,10 @@ public: void TestMissingProperty() { //Mantid.noses is not defined in the properties script - TS_ASSERT_THROWS_ANYTHING( std::string legCountString = configSvc->getString("mantid.noses")); + std::string noseCountString = configSvc->getString("mantid.noses"); + //this should return an empty string + + TS_ASSERT_EQUALS(noseCountString, ""); } diff --git a/Code/Mantid/Kernel/test/TimeSeriesPropertyTest.h b/Code/Mantid/Kernel/test/TimeSeriesPropertyTest.h index 827be373c42..fbb0091d759 100644 --- a/Code/Mantid/Kernel/test/TimeSeriesPropertyTest.h +++ b/Code/Mantid/Kernel/test/TimeSeriesPropertyTest.h @@ -62,11 +62,11 @@ public: void testValue() { const std::string dString = dProp->value(); - TS_ASSERT_EQUALS( dString.substr(0,30), "Fri Nov 30 16:17:00 2007 9.99" ); + TS_ASSERT_EQUALS( dString.substr(0,27), "2007-Nov-30 16:17:00 9.99\n" ); const std::string iString = iProp->value(); - TS_ASSERT_EQUALS( iString.substr(0,27), "Fri Nov 30 16:17:00 2007 1" ); + TS_ASSERT_EQUALS( iString.substr(0,24), "2007-Nov-30 16:17:00 1\n" ); const std::string sString = sProp->value(); - TS_ASSERT_EQUALS( sString.substr(0,30), "Fri Nov 30 16:17:00 2007 test" ); + TS_ASSERT_EQUALS( sString.substr(0,27), "2007-Nov-30 16:17:00 test\n" ); } void testCasting() diff --git a/Code/Mantid/Kernel/test/runTests.bat b/Code/Mantid/Kernel/test/runTests.bat index fe987f2490b..55b23913180 100644 --- a/Code/Mantid/Kernel/test/runTests.bat +++ b/Code/Mantid/Kernel/test/runTests.bat @@ -21,7 +21,7 @@ GOTO COMPILE :COMPILE echo "Compiling the test executable..." -cl runner.cpp /I "..\..\..\Third_Party\include" /I "..\.." /I "../../API/inc" /I "..\inc" /EHsc /MDd /W3 /wd4275 /nologo /c /ZI /TP +cl runner.cpp /I "..\..\..\Third_Party\include" /I "..\.." /I "../../API/inc" /I "..\inc" /D_CRT_SECURE_NO_DEPRECATE /EHsc /MDd /W3 /wd4275 /nologo /c /ZI /TP link /OUT:"runner.exe" /NOLOGO /LIBPATH:"../../Debug" /LIBPATH:"../../../Third_Party/lib/win32" /DEBUG /PDB:".\runner.pdb" Mantidkernel.lib MantidApi.lib runner.obj diff --git a/Code/Mantid/Main/Main.cpp b/Code/Mantid/Main/Main.cpp index 69c2f878f37..4f0a04aadd4 100644 --- a/Code/Mantid/Main/Main.cpp +++ b/Code/Mantid/Main/Main.cpp @@ -16,7 +16,7 @@ int main() { FrameworkManager* fm = FrameworkManager::Instance(); - fm->initialize(); + fm->initialize(); Benchmark b; b.RunPlusTest(); -- GitLab