Project

General

Profile

« Previous | Next » 

Revision 1535

xml_func.py: _date: On error "month must be in 1..12", try swapping month and day

View differences:

lib/xml_func.py
256 256
        items = dict(conv_items(int, items.iteritems()))
257 257
        items.setdefault('month', 1)
258 258
        items.setdefault('day', 1)
259
        try: date = datetime.date(**items)
260
        except ValueError, e: raise SyntaxException(e)
259
        
260
        for try_num in xrange(2):
261
            try:
262
                date = datetime.date(**items)
263
                break
264
            except ValueError, e:
265
                msg = str(e)
266
                if msg == 'month must be in 1..12': # try swapping month and day
267
                    items['month'], items['day'] = items['day'], items['month']
268
                else: raise SyntaxException(e)
261 269
    else:
262 270
        try: year = float(str_)
263 271
        except ValueError:

Also available in: Unified diff