FieldTypes.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifdef _MSC_VER
00021 #include "stdafx.h"
00022 #else
00023 #include "config.h"
00024 #endif
00025 #include "CallStack.h"
00026
00027 #include "FieldTypes.h"
00028
00029 #ifdef HAVE_FTIME
00030 # include <sys/timeb.h>
00031 #endif
00032
00033 namespace FIX {
00034
00035 DateTime DateTime::nowUtc()
00036 {
00037 #if defined( HAVE_FTIME )
00038 timeb tb;
00039 ftime (&tb);
00040 return fromUtcTimeT (tb.time, tb.millitm);
00041 #elif defined( _POSIX_SOURCE )
00042 struct timeval tv;
00043 gettimeofday (&tv, 0);
00044 return fromUtcTimeT( tv.tv_sec, tv.tv_usec / 1000 );
00045 #else
00046 return fromUtcTimeT( ::time (0), 0 );
00047 #endif
00048 }
00049
00050 DateTime DateTime::nowLocal()
00051 {
00052 #if defined( HAVE_FTIME )
00053 timeb tb;
00054 ftime (&tb);
00055 return fromLocalTimeT( tb.time, tb.millitm );
00056 #elif defined( _POSIX_SOURCE )
00057 struct timeval tv;
00058 gettimeofday (&tv, 0);
00059 return fromLocalTimeT( tv.tv_sec, tv.tv_usec / 1000 );
00060 #else
00061 return fromLocalTimeT( ::time (0), 0 );
00062 #endif
00063 }
00064
00065 }