gtime.cpp

来自「一个由Mike Gashler完成的机器学习方面的includes neural」· C++ 代码 · 共 47 行

CPP
47
字号
/*	Copyright (C) 2006, Mike Gashler	This library is free software; you can redistribute it and/or	modify it under the terms of the GNU Lesser General Public	License as published by the Free Software Foundation; either	version 2.1 of the License, or (at your option) any later version.	see http://www.gnu.org/copyleft/lesser.html*/#include <stdio.h>#include "GTime.h"#include "GString.h"#include <time.h>#ifdef WIN32#include <windows.h>#else // WIN32#include <sys/time.h>#endif // else WIN32/*static*/ double GTime::GetTime(){#ifdef WIN32	time_t t;	SYSTEMTIME st;	GetSystemTime(&st);	return ((double)st.wMilliseconds * 1e-3 + time(&t));#else	struct timeval tp;    gettimeofday(&tp, NULL);    return ((double)tp.tv_sec + (double)tp.tv_usec * 1e-6);#endif}/*static*/ const char* GTime::GetAsciiTime(char* szBuf, int nSize){	time_t t = time((time_t*)0);	struct tm* pTime = gmtime(&t);	int len = GString::StrCpy(szBuf, asctime(pTime), nSize);	// Remove trailing whitespace (cuz asctime appends a '\n' at the end)	while(len > 0 && szBuf[len - 1] <= ' ')		szBuf[--len] = '\0';	return szBuf;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?