/* * Copyright (C) 2000-2004 Absolute Performance, Inc. * All Rights Reserved * * THIS IS PROPRIETARY SOFTWARE DEVELOPED FOR THE SYSSHEP PROJECT AT * ABSOLUTE PERFORMANCE, INC.; IT MAY NOT BE DISCLOSED TO THIRD PARTIES, * COPIED OR DUPLICATED IN ANY FORM, IN WHOLE OR IN PART, WITHOUT THE PRIOR * WRITTEN PERMISSION OF ABSOLUTE PERFORMANCE, INC. * * FURTHERMORE, THIS SOFTWARE IS DISTRIBUTED AS IS, AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NOT EVENT SHALL ABSOLUTE PERFORMANCE BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE AND OTHERWISE) ARISING IN ANY * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. RECEIVING PARTY MAY NOT REVERSE ENGINEER, DECOMPILE OR * DISASSEMBLE ANY SOFTWARE DISCLOSED TO RECEIVING PARTY. * * Author: Michael Linck 7/07 */ #ifndef TIME_TEST_H #define TIME_TEST_H // our includes // tp includes #include #include // std includes //############################################################################# /** */ //############################################################################# class TimeTest : public CxxTest::TestSuite { public: //######################################################################### //######################################################################### void testTime() { typedef boost::date_time::time_facet BoostTimeOutputFacetTS; typedef boost::date_time::time_input_facet BoostTimeInputFacetTS; // standard HTTP format, can't possibly have a useful library if you // can't read and write these std::string tFacetFormat("%a, %d %b %Y %H:%M:%S %Z"); BoostTimeInputFacetTS * _InputFacet (new BoostTimeInputFacetTS(tFacetFormat.c_str())); BoostTimeOutputFacetTS * _OutputFacet (new BoostTimeOutputFacetTS(tFacetFormat.c_str())); std::stringstream tTimeStream; tTimeStream.imbue(std::locale(std::locale::classic(), _InputFacet)); tTimeStream.imbue(std::locale(std::locale::classic(), _OutputFacet)); std::string tFirstConvertedString; std::string tSecondConvertedString; std::time_t tConvertedTime; // Thu Apr 2 14:33:23 MDT 2009 std::time_t tTime(1238704403); std::cout<<"parse::tTime #"<> fails to modify it. boost::posix_time::ptime tSecondPTime; tTimeStream.str(tFirstConvertedString); // fails, does not modify tSecondPTime so you get "not-a-date-time" tTimeStream>>tSecondPTime; std::cout<<"parse::tSecondPTime #"<