libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
SystemTime.hpp
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright © 2002 by J.M.McGuiness, coder@hussar.me.uk
3 **
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Lesser General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2.1 of the License, or (at your option) any later version.
8 **
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser General Public
15 ** License along with this library; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
19 #pragma once
20 
21 #include"../../../core/ttypes.hpp"
22 #include<iomanip>
23 #include<ostream>
24 #include<sstream>
25 #include<string>
26 
27 namespace jmmcg {
28 
29  namespace NTUtils {
30 
32  SYSTEMTIME time;
33  ::GetSystemTime(&time);
34  ss<<std::setw(2)<<std::setfill(_T('0'))<<time.wHour<<_T(':')
35  <<std::setw(2)<<std::setfill(_T('0'))<<time.wMinute<<_T(':')
36  <<std::setw(2)<<std::setfill(_T('0'))<<time.wSecond<<_T('.')
37  <<std::setw(3)<<std::setfill(_T('0'))<<time.wMilliseconds<<_T(" - ")
38  <<std::setw(2)<<std::setfill(_T('0'))<<time.wDay<<_T('/')
39  <<std::setw(2)<<std::setfill(_T('0'))<<time.wMonth<<_T('/')
40  <<std::setw(2)<<std::setfill(_T('0'))<<time.wYear;
41  return ss;
42  }
43 
44  inline tstring SystemTimeAsStr(void) {
45  tstringstream ss;
46  SystemTime(ss);
47  return ss.str();
48  }
49 
50  }
51 
52 }