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 
34 DateTime DateTime::nowUtc()
35 {
36 #if defined( _POSIX_SOURCE ) || defined(HAVE_GETTIMEOFDAY)
37  struct timeval tv;
38  gettimeofday (&tv, 0);
39  return fromUtcTimeT( tv.tv_sec, tv.tv_usec, 6 );
40 #elif defined( HAVE_FTIME )
41  timeb tb;
42  ftime (&tb);
43  return fromUtcTimeT (tb.time, tb.millitm);
44 #else
45  return fromUtcTimeT( ::time (0), 0 );
46 #endif
47 }
48 
49 DateTime DateTime::nowLocal()
50 {
51 #if defined( _POSIX_SOURCE ) || defined(HAVE_GETTIMEOFDAY)
52  struct timeval tv;
53  gettimeofday (&tv, 0);
54  return fromLocalTimeT( tv.tv_sec, tv.tv_usec, 6 );
55 #elif defined( HAVE_FTIME )
56  timeb tb;
57  ftime (&tb);
58  return fromLocalTimeT( tb.time, tb.millitm );
59 #else
60  return fromLocalTimeT( ::time (0), 0 );
61 #endif
62 }
63 
64 }
FIX::DateTime::nowLocal
static DateTime nowLocal()
Return the current wall-clock time as a local DateTime.
Definition: FieldTypes.cpp:66
FIX::DateTime::fromUtcTimeT
static DateTime fromUtcTimeT(time_t t, int millis=0)
Convert a time_t and optional milliseconds to a DateTime.
Definition: FieldTypes.h:485
FIX
Definition: Acceptor.cpp:34
FIX::DateTime::nowUtc
static DateTime nowUtc()
Return the current wall-clock time as a utc DateTime.
Definition: FieldTypes.cpp:51
FIX::DateTime::fromLocalTimeT
static DateTime fromLocalTimeT(time_t t, int millis=0)
Definition: FieldTypes.h:491
FieldTypes.h

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2001