Mercurial > defical
comparison defical-c/src/basic/inefficient.cpp @ 0:ebed2bd0d300
Initial import from svn. History be damned.
author | Edho P. Arief <me@myconan.net> |
---|---|
date | Fri, 02 Apr 2010 23:11:57 +0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ebed2bd0d300 |
---|---|
1 #include <sstream> | |
2 #include "inefficient.h" | |
3 | |
4 string uint32_t_to_str(uint32_t myint) | |
5 { | |
6 stringstream tempstr; | |
7 tempstr<<myint; | |
8 return tempstr.str(); | |
9 } | |
10 | |
11 double stdev(uint32_t * numbers) | |
12 { | |
13 //TODO | |
14 return 0; | |
15 } | |
16 | |
17 gettime::gettime() | |
18 { | |
19 uint32_t year,month,day,hour,min,sec; | |
20 #ifdef _MSC_VER | |
21 SYSTEMTIME st; | |
22 GetLocalTime(&st); | |
23 char temp[5]; | |
24 sprintf_s(temp,5,"%04d",st.wYear); | |
25 year=atoi(temp); | |
26 sprintf_s(temp,3,"%02d",st.wMonth); | |
27 month=atoi(temp); | |
28 sprintf_s(temp,3,"%02d",st.wDay); | |
29 day=atoi(temp); | |
30 sprintf_s(temp,3,"%02d",st.wHour); | |
31 hour=atoi(temp); | |
32 sprintf_s(temp,3,"%02d",st.wMinute); | |
33 min=atoi(temp); | |
34 sprintf_s(temp,3,"%02d",st.wSecond); | |
35 sec=atoi(temp); | |
36 sprintf_s(time_v,20,"%04d-%02d-%02d %02d:%02d:%02d",year,month,day,hour,min,sec); | |
37 sprintf_s(time_s,16,"%04d%02d%02d_%02d%02d%02d",year,month,day,hour,min,sec); | |
38 #else | |
39 struct tm *mytm; | |
40 time_t mytime; | |
41 time(&mytime); | |
42 mytm=gmtime(&mytime); | |
43 year=mytm->tm_year+1900; | |
44 month=mytm->tm_mon+1; | |
45 day=mytm->tm_mday; | |
46 hour=mytm->tm_hour; | |
47 min=mytm->tm_min; | |
48 sec=mytm->tm_sec; | |
49 sprintf(time_v,"%04d-%02d-%02d %02d:%02d:%02d",year,month,day,hour,min,sec); | |
50 sprintf(time_s,"%04d%02d%02d_%02d%02d%02d",year,month,day,hour,min,sec); | |
51 #endif | |
52 } |