from datetime import datetime


def time_compare(a, b=None):
    """ Compare datetime objects a and b. If a < b, that is, a means time
        before b, return -1. If b < a, return 1. Otherwise return 0.

        If b is not given, assume b is now. """

    if b == None:
        b = datetime.now()
    if a < b:
        return -1
    if b < a:
        return 1
    return 0