def validate_date(date):
    '''validate dd-mm-yyyy'''
    import re
    import mx.DateTime
    pattern = r'(\d\d)-(\d\d)-(\d\d\d\d)'
    regex = re.compile(pattern)
    match = regex.match(date)
    if match:
        part = match.groups()
        out = True
        try:
            mx.DateTime.DateTime(int(part[2]), int(part[1]), int(part[0]))
        except:
            out = False
        return out
    return False
 
python/date.txt · Last modified: 2007/10/31 01:08 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki