Changeset 3877

Show
Ignore:
Timestamp:
01/16/08 23:18:58 (7 months ago)
Author:
paul
Message:

Well, I backtracked again. Because time.strftime() and time.strptime() are the
functions we need to go back and forth from string to date, and because I
couldn't find how to get the format string in a platform-portable way, I
removed the dabo.settings.dateFormat attribute. Now, we just call the time
module functions directly, which will do the right thing. If a dabo app
developer wants a different date format than that provided by the os, then
they'll need to figure out how to change the date format in the os
programmatically first.

Everyone test! All platforms!

Files:

Legend:

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

    r3875 r3877  
    2929        exp = "^%(month)s%(day)s$" 
    3030    else: 
    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 
     31        return None 
    4232    return re.compile(exp % elements) 
    4333 
     
    122112        if ret is not None: 
    123113            break    
     114    if ret is None: 
     115        ## Fall back to the current locale setting: 
     116        try: 
     117            ret = datetime.date(*time.strptime(strVal, "%x")[:3]) 
     118        except: 
     119            ret = None 
    124120    return ret 
    125121 
  • branches/paul/dabo/lib/reportWriter.py

    r3848 r3877  
    7373    ParaClass = platypus.Paragraph 
    7474 
    75 # Pretty sure we want to do this way earlier in Dabo,  
    76 # but this gets it working for me: 
    77 locale.setlocale(locale.LC_ALL, '') 
    7875 
    7976def toPropDict(dataType, default, doc): 
  • branches/paul/dabo/settings.py

    r3873 r3877  
    11# -*- coding: utf-8 -*- 
    2 import locale 
    32 
    43# Dabo Global Settings 
     
    113112checkForWebUpdates = True 
    114113 
    115 dateFormat = locale.nl_langinfo(locale.D_FMT) 
    116 datetimeFormat = locale.nl_langinfo(locale.D_T_FMT) 
    117114 
    118115### Settings - end 
  • branches/paul/dabo/ui/uiwx/dGrid.py

    r3873 r3877  
    33import sys 
    44import datetime 
    5 import local
     5import tim
    66import operator 
    77import re 
     
    349349        """Get the string value to display in the grid.""" 
    350350        if isinstance(val, datetime.date): 
    351             return val.strftime(dabo.settings.dateFormat
     351            return time.strftime("%x", (val.year, val.month, val.day, 0, 0, 0, 0, 0, 0)
    352352        return val 
    353353 
  • branches/paul/dabo/ui/uiwx/dTextBoxMixin.py

    r3875 r3877  
    22import re 
    33import datetime 
     4import time 
    45import locale 
    56import wx 
     
    513514            strVal = value.isoformat(" ") 
    514515        elif isinstance(value, datetime.date): 
    515             # Use the ISO 8601 date string format so we can convert 
    516             # back from a known quantity later... 
    517             #strVal = value.isoformat() 
    518             strVal = value.strftime(dabo.settings.dateFormat) 
     516            strVal = time.strftime("%x", (value.year, value.month, value.day, 0, 0, 0, 0, 0, 0)) 
    519517        elif isinstance(value, datetime.time): 
    520518            # Use the ISO 8601 time string format