Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
Functions
TimeFunctions.h File Reference

implements of function which deals with time More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

long long getcurrenttime ()
 gets current time in miliseconds More...
 
std::string datetostring (struct tm *date)
 date -> string More...
 

Detailed Description

implements of function which deals with time

interfaces of function which deals with time

Author
S.Tanaka
Date
2009.08.31

Copyright(C) 2006-2014 Eisai Co., Ltd. All rights reserved.

Definition in file TimeFunctions.h.

Function Documentation

std::string datetostring ( struct tm *  date)

date -> string

Parameters
[in]datedate object
Returns
the date formatted as a string in the format DD MONTH YEAR HH:MM:SS, e.g. 19 Mar 2012 09:51:30

Definition at line 53 of file TimeFunctions.cpp.

53  {
54 
55  std::string strDate;
56 
57  if (date != NULL)
58  {
59  wxDateTime wxWidDate(*date);
60  strDate = FMT( "%02d %s %04d %02d:%02d:%02d", wxWidDate.GetDay(), wxDateTime::GetMonthName(wxWidDate.GetMonth(), wxDateTime::Name_Abbr).c_str(), wxWidDate.GetYear(),
61  wxWidDate.GetHour(), wxWidDate.GetMinute(), wxWidDate.GetSecond());
62  }
63  else
64  {
65  strDate = "";
66  }
67 
68  return strDate;
69 }
#define NULL
Definition: CoreMacros.h:18
long long getcurrenttime ( )

gets current time in miliseconds

Returns
the difference between the current time and midnight, Jan 1, 1970.

Definition at line 27 of file TimeFunctions.cpp.

27  {
28  long long t = 0;
29 
30 // get time
31 #ifdef _MSC_VER
32  FILETIME ft;
33  LARGE_INTEGER lv;
34  long long v64;
35 
36  GetSystemTimeAsFileTime( &ft );
37  lv.LowPart = ft.dwLowDateTime;
38  lv.HighPart = ft.dwHighDateTime;
39 
40  v64 = lv.QuadPart - EPOCH_FILE_TIME;
41  t = v64 / 10000;
42 #else
43  struct timeval tv;
44  gettimeofday( &tv, NULL );
45 
46  t = tv.tv_sec * 1000 + tv.tv_usec / 1000;
47 #endif // _MSC_VER
48 
49  return t;
50 }
#define NULL
Definition: CoreMacros.h:18