def next_date_value(timex: Timex, date: datetime): if (timex.month and timex.day_of_month) is not None: return TimexValue.date_value( Timex(year=date.year, month=timex.month, day_of_month=timex.day_of_month)) if timex.day_of_week is not None: day = Constants.DAYS[ 'SUNDAY'] if timex.day_of_week == 6 else timex.day_of_week result = TimexDateHelpers.date_of_next_day(day - 1, date) return TimexValue.date_value( Timex(year=result.year, month=result.month, day_of_month=result.day)) return ''
def test_datatypes_datehelpers_dateofnextday_wednesday_nextweek(): day = Constants.DAYS['WEDNESDAY'] date = datetime(2017, 9, 28) assert datetime(2017, 10, 4) == TimexDateHelpers.date_of_next_day(day, date)
def test_datatypes_datehelpers_dateofnextday_today(): day = Constants.DAYS['THURSDAY'] date = datetime(2017, 9, 28) assert date != TimexDateHelpers.date_of_next_day(day, date)