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
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':
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):