Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(3)  |  Call(3)  |  Derive(0)  |  Import(0)
Validation function.  Converts from YYYY-MM-DD or YYYY/MM/DD
format to a (long) time value for midnight on that date.

        def _parseDate(s):
    """Validation function.  Converts from YYYY-MM-DD or YYYY/MM/DD
       format to a (long) time value for midnight on that date."""
    m = _date_re.match(s.strip())
    if not m or m.group(2) != m.group(4):
        raise ConfigError("Invalid date %r"%s)
    try:
        yyyy = int(m.group(1))
        MM = int(m.group(3))
        dd = int(m.group(5))
    except (ValueError,AttributeError):
        raise ConfigError("Invalid date %r"%s)
    if not ((1 <= dd <= 31) and (1 <= MM <= 12) and
            (1970 <= yyyy)):
        raise ConfigError("Invalid date %r"%s)
    return calendar.timegm((yyyy,MM,dd,0,0,0,0,0,0))
        


src/m/i/mixminion-HEAD/lib/mixminion/test.py   mixminion(Download)
        self.assertEquals(C._parseHex(" C0\n D 0"), "\xC0\xD0")
        # Date
        tm = C._parseDate("2002/05/30")
        self.assertEquals(time.gmtime(tm)[:6], (2002,5,30,0,0,0))
        tm = C._parseDate("2000/01/01")
        self.assertEquals(time.gmtime(tm)[:6], (2000,1,1,0,0,0))
        tm = C._parseDate("2000-05-03")