[pywin32-checkins] pywin32/win32/src win32apimodule.cpp,1.45,1.46
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-03-04 11:51:00
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6593/src Modified Files: win32apimodule.cpp Log Message: Add GetDateFormat/GetTimeFormat Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** win32apimodule.cpp 9 Feb 2005 08:18:52 -0000 1.45 --- win32apimodule.cpp 4 Mar 2005 11:50:32 -0000 1.46 *************** *** 1835,1838 **** --- 1835,1888 ---- } + // @pymethod string|win32api|GetDateFormat|Formats a date as a date string for a specified locale. The function formats either a specified date or the local system date. + static PyObject *PyGetDateFormat(PyObject *self, PyObject *args) + { + int locale, flags; + PyObject *obTime; + char *szFormat = NULL; + if (!PyArg_ParseTuple(args, "iiO|z:GetDateFormat", + &locale, // @pyparm int|locale|| + &flags, // @pyparm int|flags|| + &obTime, // @pyparm <o PyTime>|time||The time to use, or None to use the current time. + &szFormat)) // @pyparm string|format||May be None + return NULL; + SYSTEMTIME st, *pst = NULL; + if (obTime != Py_None) { + if (!PyWinObject_AsSYSTEMTIME(obTime, &st)) + return NULL; + pst = &st; + } + char buf[512]; + int nchars = ::GetDateFormat(locale, flags, pst, szFormat, buf, sizeof(buf)/sizeof(buf)[0]); + if (nchars==0) + return PyWin_SetAPIError("GetDateFormat"); + return PyString_FromStringAndSize(buf, nchars-1); + } + + // @pymethod string|win32api|GetTimeFormat|Formats a time as a time string for a specified locale. The function formats either a specified time or the local system time. + static PyObject *PyGetTimeFormat(PyObject *self, PyObject *args) + { + int locale, flags; + PyObject *obTime; + char *szFormat = NULL; + if (!PyArg_ParseTuple(args, "iiO|z:GetTimeFormat", + &locale, // @pyparm int|locale|| + &flags, // @pyparm int|flags|| + &obTime, // @pyparm <o PyTime>|time||The time to use, or None to use the current time. + &szFormat)) // @pyparm string|format||May be None + return NULL; + SYSTEMTIME st, *pst = NULL; + if (obTime != Py_None) { + if (!PyWinObject_AsSYSTEMTIME(obTime, &st)) + return NULL; + pst = &st; + } + char buf[512]; + int nchars = ::GetTimeFormat(locale, flags, pst, szFormat, buf, sizeof(buf)/sizeof(buf)[0]); + if (nchars==0) + return PyWin_SetAPIError("GetTimeFormat"); + return PyString_FromStringAndSize(buf, nchars-1); + } + // @pymethod int|win32api|GetSysColor|Returns the current system color for the specified element. static PyObject * *************** *** 4605,4608 **** --- 4655,4659 ---- {"GetCurrentProcess", PyGetCurrentProcess, 1}, // @pymeth GetCurrentProcess|Returns a pseudohandle for the current process. {"GetConsoleTitle", PyGetConsoleTitle, 1}, // @pymeth GetConsoleTitle|Return the application's console title. + {"GetDateFormat", PyGetDateFormat, 1}, // @pymeth GetDateFormat|Formats a date as a date string for a specified locale. {"GetDiskFreeSpace", PyGetDiskFreeSpace, 1}, // @pymeth GetDiskFreeSpace|Retrieves information about a disk. {"GetDiskFreeSpaceEx", PyGetDiskFreeSpaceEx, 1}, // @pymeth GetDiskFreeSpaceEx|Retrieves information about a disk. *************** *** 4638,4641 **** --- 4689,4693 ---- {"GetThreadLocale", PyGetThreadLocale, 1}, // @pymeth GetThreadLocale|Returns the current thread's locale. {"GetTickCount", PyGetTickCount, 1}, // @pymeth GetTickCount|Returns the milliseconds since windows started. + {"GetTimeFormat", PyGetTimeFormat, 1}, // @pymeth GetTimeFormat|Formats a time as a time string for a specified locale. {"GetTimeZoneInformation", PyGetTimeZoneInformation,1}, // @pymeth GetTimeZoneInformation|Returns the system time-zone information. {"GetVersion", PyGetVersion, 1}, // @pymeth GetVersion|Returns Windows version information. |