From: Christian P. <cp...@us...> - 2004-12-28 20:19:53
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29088/src/System Added Files: SystemClock.win32.cpp Log Message: Added win32 implementation of SystemClock class --- NEW FILE: SystemClock.win32.cpp --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "pclasses/System/SystemClock.h" #include <windows.h> namespace P { namespace System { DateTime SystemClock::now(NowMode mode) { SYSTEMTIME st; std::string tzname; switch(mode) { case Local: tzname = currentTimeZone(); GetLocalTime(&st); break; case UTC: tzname = "UTC"; GetSystemTime(&st); break; }; return DateTime(Date(st.wYear, st.wMonth, st.wDay), Time(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds * 1000), tzname); } std::string SystemClock::timeZone() { time_t timet = time(0); std::string tz_name; struct tm* currtm = localtime(&timet); char tmp[256]; sprintf(tmp, "GMT%+d", -(_timezone / 3600)); tz_name = tmp; /*if(!currtm) tz_name = tzname[0]; else tz_name = currtm->tm_isdst > 0 ? _tzname[1] : _tzname[0];*/ return tz_name; } } // !namespace System } // !namespace P |