mirror of
https://github.com/boostorg/date_time.git
synced 2026-02-24 03:52:16 +00:00
https://svn.boost.org/svn/boost/trunk ........ r43417 | danieljames | 2008-02-26 22:04:55 +0000 (Tue, 26 Feb 2008) | 2 lines Fix a link to Boost.Bimap. ........ r43418 | danieljames | 2008-02-26 22:07:25 +0000 (Tue, 26 Feb 2008) | 2 lines Change another link that's no longer in the repository to link to the website. ........ r43422 | danieljames | 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) | 1 line Fix broken copyright urls. Fixes #1573. ........ r43423 | danieljames | 2008-02-27 19:22:01 +0000 (Wed, 27 Feb 2008) | 1 line Fix incorrect links to copyright of the form 'http:#www.boost.org ........ [SVN r43425]
70 lines
2.0 KiB
C++
70 lines
2.0 KiB
C++
/* Copyright (c) 2002,2003, 2004 CrystalClear Software, Inc.
|
|
* Use, modification and distribution is subject to the
|
|
* Boost Software License, Version 1.0. (See accompanying
|
|
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
|
* Author: Jeff Garland, Bart Garst
|
|
*/
|
|
|
|
#include "boost/date_time/posix_time/posix_time.hpp"
|
|
#include "boost/date_time/testfrmwk.hpp"
|
|
#include "boost/date_time/filetime_functions.hpp"
|
|
#include <cmath>
|
|
|
|
#if defined(BOOST_HAS_FTIME)
|
|
#include <windows.h>
|
|
#endif
|
|
|
|
int main()
|
|
{
|
|
#if defined(BOOST_HAS_FTIME) // skip tests if no FILETIME
|
|
|
|
using namespace boost::posix_time;
|
|
|
|
// adjustor is used to truncate ptime's fractional seconds for
|
|
// comparison with SYSTEMTIME's milliseconds
|
|
const int adjustor = time_duration::ticks_per_second() / 1000;
|
|
|
|
for(int i = 0; i < 5; ++i){
|
|
|
|
FILETIME ft;
|
|
SYSTEMTIME st;
|
|
GetSystemTime(&st);
|
|
SystemTimeToFileTime(&st,&ft);
|
|
|
|
ptime pt = from_ftime<ptime>(ft);
|
|
|
|
check("ptime year matches systemtime year",
|
|
st.wYear == pt.date().year());
|
|
check("ptime month matches systemtime month",
|
|
st.wMonth == pt.date().month());
|
|
check("ptime day matches systemtime day",
|
|
st.wDay == pt.date().day());
|
|
check("ptime hour matches systemtime hour",
|
|
st.wHour == pt.time_of_day().hours());
|
|
check("ptime minute matches systemtime minute",
|
|
st.wMinute == pt.time_of_day().minutes());
|
|
check("ptime second matches systemtime second",
|
|
st.wSecond == pt.time_of_day().seconds());
|
|
check("truncated ptime fractional second matches systemtime millisecond",
|
|
st.wMilliseconds == (pt.time_of_day().fractional_seconds() / adjustor)
|
|
);
|
|
|
|
// burn up a little time
|
|
for (int j=0; j<100000; j++)
|
|
{
|
|
SYSTEMTIME tmp;
|
|
GetSystemTime(&tmp);
|
|
}
|
|
|
|
} // for loop
|
|
|
|
#else // BOOST_HAS_FTIME
|
|
// we don't want a forced failure here, not a shortcoming
|
|
check("FILETIME not available for this compiler/platform", true);
|
|
#endif // BOOST_HAS_FTIME
|
|
|
|
return printTestStats();
|
|
|
|
}
|
|
|