Ticket #471: dateTimeFix.patch

File dateTimeFix.patch, 2.0 KB (added by pvagner, 2 years ago)
  • source/appModules/_default.py

    === modified file 'source/appModules/_default.py'
     
    9393 
    9494        def script_dateTime(self,keyPress): 
    9595                if scriptHandler.getLastScriptRepeatCount()==0: 
    96                         text=winKernel.GetTimeFormat(winKernel.getThreadLocale(), winKernel.TIME_NOSECONDS, None, None) 
     96                        text=winKernel.GetTimeFormat(winKernel.LOCALE_USER_DEFAULT, winKernel.TIME_NOSECONDS, None, None) 
    9797                else: 
    98                         text=winKernel.GetDateFormat(winKernel.getThreadLocale(), winKernel.DATE_LONGDATE, None, None) 
     98                        text=winKernel.GetDateFormat(winKernel.LOCALE_USER_DEFAULT, winKernel.DATE_LONGDATE, None, None) 
    9999                ui.message(text) 
    100100        script_dateTime.__doc__=_("If pressed once, reports the current time. If pressed twice, reports the current date") 
    101101 
  • source/winKernel.py

    === modified file 'source/winKernel.py'
     
    7070 
    7171def GetSystemPowerStatus(sps): 
    7272        return kernel32.GetSystemPowerStatus(ctypes.byref(sps)) 
     73 
    7374def getThreadLocale(): 
    7475        return kernel32.GetThreadLocale() 
    7576 
    7677def GetDateFormat(Locale,dwFlags,lpDate,lpFormat): 
    77         buf=ctypes.create_unicode_buffer("", 32) 
    78         kernel32.GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, buf, ctypes.sizeof(buf)) 
     78        bufferLength=kernel32.GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, None, 0) 
     79        buf=ctypes.create_unicode_buffer("", bufferLength) 
     80        kernel32.GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, buf, bufferLength) 
    7981        return buf.value 
    8082 
    8183def GetTimeFormat(Locale,dwFlags,lpTime,lpFormat): 
    82         buf=ctypes.create_unicode_buffer("", 32) 
    83         kernel32.GetTimeFormatW(Locale,dwFlags,lpTime,lpFormat, buf, ctypes.sizeof(buf)) 
     84        bufferLength=kernel32.GetTimeFormatW(Locale,dwFlags,lpTime,lpFormat, None, 0) 
     85        buf=ctypes.create_unicode_buffer("", bufferLength) 
     86        kernel32.GetTimeFormatW(Locale,dwFlags,lpTime,lpFormat, buf, bufferLength) 
    8487        return buf.value 
    8588 
    8689def openProcess(*args):