Adding some suggestions from Jerome.
Using __main__, def main:
Changed date processing