#!/usr/bin/env python

import urllib, re

TIME_URL = "http://www.time.gov/timezone.cgi?Central/d/-6"

TIME_PATTERN = r"<b>(\d\d:\d\d:\d\d)"
DATE_PATTERN = r'</b></font><font size="5" color="white">([^<]*)<'

TD_RE = re.compile(TIME_PATTERN+".*"+DATE_PATTERN, re.DOTALL)

def main():
    # fetch the time url html
    html = urllib.urlopen(TIME_URL).read()

    # extract time and date information
    match = TD_RE.search(html)
    if match:
        print "Date:", match.group(2)
        print "Time:", match.group(1)
    else:
        print "ERROR: Did not match date and time in HTML received"

if __name__ == "__main__":
    main()

    
    
