def time_expression(Hour=None, Minute=None, Second=None, AMPM=None, SpecialTimeText=None): if SpecialTimeText: if SpecialTimeText.lower() == "noon": return Date(hour=12) if SpecialTimeText.lower() == "midnight": return Date(hour=0) d = Date() if Hour: d = d._replace(hour=int(Hour)) if Minute: d = d._replace(minute=int(Minute)) if Second: d = d._replace(second=int(Second)) if AMPM is not None: if d.hour: if noon(d.hour, AMPM): d = d._replace(hour=12) elif midnight(d.hour, AMPM): d = d._replace(hour=0) else: d = d._replace(hour=d.hour + AMPM) d = d._replace(am_pm=AMPM) if (d.hour, d.minute, d.second) != (None, None, None): return d
def basic_text(time=None, first_second=None, weekday=None, month=None, day=None, year=None): if not day: day = 1 if not time: return Date(year=year, month=month, day=day) if time: date = Date(year=year, month=month, day=day) return date._replace(hour=time.hour, minute=time.minute, second=time.second, am_pm=time.am_pm)