Mercurial > defical
view 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 |
line wrap: on
line source
#include <sstream> #include "inefficient.h" string uint32_t_to_str(uint32_t myint) { stringstream tempstr; tempstr<<myint; return tempstr.str(); } double stdev(uint32_t * numbers) { //TODO return 0; } gettime::gettime() { uint32_t year,month,day,hour,min,sec; #ifdef _MSC_VER SYSTEMTIME st; GetLocalTime(&st); char temp[5]; sprintf_s(temp,5,"%04d",st.wYear); year=atoi(temp); sprintf_s(temp,3,"%02d",st.wMonth); month=atoi(temp); sprintf_s(temp,3,"%02d",st.wDay); day=atoi(temp); sprintf_s(temp,3,"%02d",st.wHour); hour=atoi(temp); sprintf_s(temp,3,"%02d",st.wMinute); min=atoi(temp); sprintf_s(temp,3,"%02d",st.wSecond); sec=atoi(temp); sprintf_s(time_v,20,"%04d-%02d-%02d %02d:%02d:%02d",year,month,day,hour,min,sec); sprintf_s(time_s,16,"%04d%02d%02d_%02d%02d%02d",year,month,day,hour,min,sec); #else struct tm *mytm; time_t mytime; time(&mytime); mytm=gmtime(&mytime); year=mytm->tm_year+1900; month=mytm->tm_mon+1; day=mytm->tm_mday; hour=mytm->tm_hour; min=mytm->tm_min; sec=mytm->tm_sec; sprintf(time_v,"%04d-%02d-%02d %02d:%02d:%02d",year,month,day,hour,min,sec); sprintf(time_s,"%04d%02d%02d_%02d%02d%02d",year,month,day,hour,min,sec); #endif }