Changeset 3875

Show
Ignore:
Timestamp:
01/15/08 13:43:55 (10 months ago)
Author:
paul
Message:

Added the ability to enter dates using the format defined in
dabo.settings.dateFormat. To work, the format string needs to have
in it, at a minimum:

%d : the day
%m : the month
%y or %Y: the year, in 2-digit or 4-digit format

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/paul/dabo/lib/dates.py

    r3054 r3875  
    2929        exp = "^%(month)s%(day)s$" 
    3030    else: 
    31         return None 
     31        conv = {"%d": "%(day)s", 
     32                "%m": "%(month)s", 
     33                "%y": "%(shortyear)s", 
     34                "%Y": "%(year)s"} 
     35        if "%d" in format and "%m" in format and ("%y" in format or "%Y" in format): 
     36            for k in conv.keys(): 
     37                format = format.replace(k, conv[k]) 
     38            format.replace(".", "\.") 
     39            exp = "^%s$" % format 
     40        else: 
     41            return None 
    3242    return re.compile(exp % elements) 
    3343 
     
    8292    if formats is None: 
    8393        formats = ["ISO8601"] 
    84      
     94 
    8595    # Try each format in order: 
    8696    for format in formats: 
  • branches/paul/dabo/ui/uiwx/dTextBoxMixin.py

    r3873 r3875  
    535535        datetime.date object, or None. 
    536536        """ 
    537         formats = ["ISO8601"] 
     537        formats = [dabo.settings.dateFormat, "ISO8601"] 
    538538        if not self.StrictDateEntry: 
    539539            # Add some less strict date-entry formats: 
     
    640640                convertedVal = self.convertStringValueToDataType(strVal, dataType) 
    641641                if self.getStringValue(convertedVal) != self.GetValue(): 
    642                     dabo.ui.callAfterInterval(50, self._updateStringDisplay) 
     642                    self._updateStringDisplay 
    643643            except ValueError: 
    644644                # It couldn't convert; return the previous value.