Project

General

Profile

« Previous | Next » 

Revision 1264

xml_func.py: Use new dates.strtotime(). When component date parts specified, year defaults to dates.epoch.year.

View differences:

lib/xml_func.py
183 183
    try: str_ = dict(items)['date']
184 184
    except KeyError:
185 185
        items = dict(filter(lambda (k, v): v != 0, conv_items(int, items)))
186
        items.setdefault('year', 1900)
186
        items.setdefault('year', dates.epoch.year)
187 187
        items.setdefault('month', 1)
188 188
        items.setdefault('day', 1)
189 189
        try: date = datetime.date(**items)
......
191 191
    else:
192 192
        try: year = float(str_)
193 193
        except ValueError:
194
            try: import dateutil.parser
194
            try: date = dates.strtotime(str_)
195 195
            except ImportError: return str_
196
            try: date = dateutil.parser.parse(str_)
197 196
            except ValueError, e: raise SyntaxException(e)
198 197
        else: date = (datetime.date(int(year), 1, 1) +
199 198
            datetime.timedelta(round((year % 1.)*365)))

Also available in: Unified diff