Patch from Will Sadkin:

Enclosed are two patches, one for timectrl, re: exceptions (now?)
    thrown on wxDateTime.strftime(%p) in a non-am/pm locale, and one
    for a problem that prevented input into the integer digit of a
    integerwidth=1 numctrl, if the current value was 0.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32483 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2005-02-28 18:45:13 +00:00
parent 7e8f0df953
commit 766abb5bc9
2 changed files with 39 additions and 19 deletions

View File

@@ -365,7 +365,13 @@ class TimeCtrl(BaseMaskedTextCtrl):
self.__fmt24hr = False
wxdt = wx.DateTimeFromDMY(1, 0, 1970)
if wxdt.Format('%p') != 'AM':
try:
if wxdt.Format('%p') != 'AM':
TimeCtrl.valid_ctrl_params['format'] = '24HHMMSS'
self.__fmt24hr = True
fmt24hr = True # force/change default positional argument
# (will countermand explicit set to False too.)
except:
TimeCtrl.valid_ctrl_params['format'] = '24HHMMSS'
self.__fmt24hr = True
fmt24hr = True # force/change default positional argument
@@ -498,10 +504,13 @@ class TimeCtrl(BaseMaskedTextCtrl):
if key == 'format':
wxdt = wx.DateTimeFromDMY(1, 0, 1970)
if wxdt.Format('%p') != 'AM':
try:
if wxdt.Format('%p') != 'AM':
require24hr = True
else:
require24hr = False
except:
require24hr = True
else:
require24hr = False
# handle both local or generic 'maskededit' autoformat codes:
if param_value == 'HHMMSS' or param_value == 'TIMEHHMMSS':
@@ -704,12 +713,15 @@ class TimeCtrl(BaseMaskedTextCtrl):
if not valid:
# deal with bug/deficiency in wx.DateTime:
if wxdt.Format('%p') not in ('AM', 'PM') and checkTime in (5,8):
# couldn't parse the AM/PM field
try:
if wxdt.Format('%p') not in ('AM', 'PM') and checkTime in (5,8):
# couldn't parse the AM/PM field
raise ValueError('cannot convert string "%s" to valid time for the current locale; please use 24hr time instead' % value)
else:
## dbg(indent=0, suspend=0)
raise ValueError('cannot convert string "%s" to valid time' % value)
except:
raise ValueError('cannot convert string "%s" to valid time for the current locale; please use 24hr time instead' % value)
else:
## dbg(indent=0, suspend=0)
raise ValueError('cannot convert string "%s" to valid time' % value)
else:
if isinstance(value, wx.DateTime):