[pywin32-checkins] pywin32/win32/src PyTime.cpp,1.7,1.8
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <mha...@us...> - 2003-10-19 11:38:49
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1:/tmp/cvs-serv1460 Modified Files: PyTime.cpp Log Message: [ 808465 ] Fix PyTime.Format, from David Fraser, as demonstrated in the new test_pywintypes.py Index: PyTime.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyTime.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyTime.cpp 10 Jan 2003 02:31:47 -0000 1.7 --- PyTime.cpp 18 Oct 2003 23:36:21 -0000 1.8 *************** *** 160,164 **** return NULL; } ! TCHAR szBuffer[128]; PyTime *pTime = (PyTime *)self; --- 160,164 ---- return NULL; } ! TCHAR szBuffer[256]; PyTime *pTime = (PyTime *)self; *************** *** 178,183 **** tm.tm_year = st.wYear - 1900; tm.tm_isdst = -1; /* have the library figure it out */ ! if (!_tcsftime(szBuffer, 128/*_countof()*/, fmt, &tm)) szBuffer[0] = '\0'; // Better error? PyObject *rc = PyWinObject_FromTCHAR(szBuffer); --- 178,191 ---- tm.tm_year = st.wYear - 1900; tm.tm_isdst = -1; /* have the library figure it out */ + /* converting to time_t and back allows us to calculate + * tm.tm_wday (day of week) and tm.tm_yday (day of year) + * though day of week is available as st.wDayOfWeek, day of year is not in st + */ + time_t time = mktime(&tm); + tm = *localtime(&time); + // tm.tm_wday = st.wDayOfWeek; + // tm.tm_yday = st. day of year; ! if (!_tcsftime(szBuffer, 256/*_countof()*/, fmt, &tm)) szBuffer[0] = '\0'; // Better error? PyObject *rc = PyWinObject_FromTCHAR(szBuffer); |