def getRandDateBetween(self, first, last): # Takes two date strings "MM-DD-YYYY" and # returns a dict of day, month, and year values # from a random date between them fDate = first.split("-") fJDate = ComicHelper.date_to_jd(int(fDate[2]), int(fDate[0]), int(fDate[1])) lDate = last.split("-") lJDate = ComicHelper.date_to_jd(int(lDate[2]), int(lDate[0]), int(lDate[1])) # Get random Julian Date randJDate = random.uniform(fJDate, lJDate) # Convert to gregorian gDate = ComicHelper.jd_to_date(randJDate) yea = int(gDate[0]) mon = int(gDate[1]) day = int(gDate[2]) # Make sure all months/days are double digits if (int(mon) < 10): mon = "0" + str(mon) if (int(day) < 10): day = "0" + str(day) # Build our dict and return it newDate = {"Year": str(yea), "Month": str(mon), "Day": str(day)} return newDate
def isDateBetween(self, check, first, last): # Takes three date strings "MM-DD-YYY" and # returns whether the first is between the next two fDate = first.split("-") fJDate = ComicHelper.date_to_jd(int(fDate[2]), int(fDate[0]), int(fDate[1])) lDate = last.split("-") lJDate = ComicHelper.date_to_jd(int(lDate[2]), int(lDate[0]), int(lDate[1])) cDate = check.split("-") cJDate = ComicHelper.date_to_jd(int(cDate[2]), int(cDate[0]), int(cDate[1])) if cJDate <= lJDate and cJDate >= fJDate: return True else: return False