René Nyffenegger's collection of things on the web | |
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
|
Win32_GetLocalTime | ||
win32_GetLocalTime.h
#include <windows.h> #include <sstream> #include <iomanip> std::string Win32_LocalTime() { SYSTEMTIME st; std::stringstream s; ::GetLocalTime(&st); s << std::setw(2) << std::setfill('0') << st.wDay << "." << std::setw(2) << std::setfill('0') << st.wMonth << "." << std::setw(4) << std::setfill('0') << st.wYear << " " << std::setw(2) << std::setfill('0') << st.wHour << ":" << std::setw(2) << std::setfill('0') << st.wMinute << ":" << std::setw(2) << std::setfill('0') << st.wSecond; return s.str(); } win32_GetLocalTime.cpp
#include <windows.h> #include <sstream> #include <iomanip> std::string Win32_LocalTime() { SYSTEMTIME st; std::stringstream s; ::GetLocalTime(&st); s << std::setw(2) << std::setfill('0') << st.wDay << "." << std::setw(2) << std::setfill('0') << st.wMonth << "." << std::setw(4) << std::setfill('0') << st.wYear << " " << std::setw(2) << std::setfill('0') << st.wHour << ":" << std::setw(2) << std::setfill('0') << st.wMinute << ":" << std::setw(2) << std::setfill('0') << st.wSecond; return s.str(); } |