from datetime import date


def days_since_refdate(yy, mm, dd, ref_year):
    #
    # Returns the number of days since reference year of AMIP dataset
    #
    d0 = date(ref_year, 1, 1)
    d1 = date(yy, mm, dd)
    delta = d1 - d0
    return delta.days


def is_leap(year):
    #
    # Leap year test
    #
    return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
