FieldTypes.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (c) 2001-2014
3 **
4 ** This file is part of the QuickFIX FIX Engine
5 **
6 ** This file may be distributed under the terms of the quickfixengine.org
7 ** license as defined by quickfixengine.org and appearing in the file
8 ** LICENSE included in the packaging of this file.
9 **
10 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12 **
13 ** See http://www.quickfixengine.org/LICENSE for licensing information.
14 **
15 ** Contact ask@quickfixengine.org if any conditions of this licensing are
16 ** not clear to you.
17 **
18 ****************************************************************************/
19 
20 #ifdef _MSC_VER
21 #include "stdafx.h"
22 #else
23 #include "config.h"
24 #endif
25 
26 #include "FieldTypes.h"
27 
28 #ifdef HAVE_FTIME
29 # include <sys/timeb.h>
30 #endif
31 
32 namespace FIX {
33 
35 {
36 #if defined( HAVE_FTIME )
37  timeb tb;
38  ftime (&tb);
39  return fromUtcTimeT (tb.time, tb.millitm);
40 #elif defined( _POSIX_SOURCE )
41  struct timeval tv;
42  gettimeofday (&tv, 0);
43  return fromUtcTimeT( tv.tv_sec, tv.tv_usec / 1000 );
44 #else
45  return fromUtcTimeT( ::time (0), 0 );
46 #endif
47 }
48 
50 {
51 #if defined( HAVE_FTIME )
52  timeb tb;
53  ftime (&tb);
54  return fromLocalTimeT( tb.time, tb.millitm );
55 #elif defined( _POSIX_SOURCE )
56  struct timeval tv;
57  gettimeofday (&tv, 0);
58  return fromLocalTimeT( tv.tv_sec, tv.tv_usec / 1000 );
59 #else
60  return fromLocalTimeT( ::time (0), 0 );
61 #endif
62 }
63 
64 }
static DateTime fromUtcTimeT(time_t t, int millis=0)
Convert a time_t and optional milliseconds to a DateTime.
Definition: FieldTypes.h:307
Definition: Acceptor.cpp:34
static DateTime fromLocalTimeT(time_t t, int millis=0)
Definition: FieldTypes.h:313
static DateTime nowUtc()
Return the current wall-clock time as a utc DateTime.
Definition: FieldTypes.cpp:34
static DateTime nowLocal()
Return the current wall-clock time as a local DateTime.
Definition: FieldTypes.cpp:49
Date and Time stored as a Julian day number and number of milliseconds since midnight.
Definition: FieldTypes.h:50

Generated on Thu Sep 5 2019 11:07:58 for QuickFIX by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001