MATLAB: Fints toweekly vs timetable retime

MATLABtimetable fints

Hello,
I have some code that used the now deprecated FINTS timeseries from the financial package. In particular I need to resample a daily series to get only the points from each wednesday and, if it is a holiday, from the previous business day. The code below shows the expected behavior:
sampleDates = (datetime(2018, 11, 30):datetime(2019, 01, 31))';
[dayNumber, dayName] = weekday(sampleDates, 'en_US');
isWorking = isbusday(sampleDates);
data = (1:length(sampleDates))';
fts = fints(datenum(sampleDates), [dayNumber, isWorking, data], {'dayNumber', 'isWorking', 'data'});
ftsWeekly = toweekly(fts, 'CalcMethod', 'Exact', 'BusDays', 1, 'EOW', 5, 'EndPtTol', [0, -1]);
I correctly get all wednesdays and the previous working day for the two cases (26.12.2018 and 02.01.2019) when it was a holiday, where it takes the previous working day.
How should I do the same with the recommended retime function on timeseries (since the fints will be removed)?
I tried the following:
tt = timetable(sampleDates, dayNumber, dayName, isWorking, data);
ttWeekly = retime(tt, 'weekly', 'nearest');
but this gives me the sunday days and I don't see how to configure it to get the wednesdays.
Any help would be great

Best Answer

retime won't know about holidays, and 'weekly' assumes you mean the start of the week (just as 'monthly' assumes start of month). But 'weekly' is just a convenience, you can always pass in an explicit vector of dates to retime to. You'll need the Financial Toolbox (or some other means) to deal with holidays, but a sequence of weds is easy:
>> fmt = 'eee dd-MMM-yyyy';
>> start = datetime(2019,2,1,'Format',fmt); stop = datetime(2019,3,1,'Format',fmt);
>> weds = dateshift(start,'dayofweek','wed','prev'):calweeks(1):dateshift(stop,'dayofweek','wed','next')
weds =
1×6 datetime array
Wed 30-Jan-2019 Wed 06-Feb-2019 Wed 13-Feb-2019 Wed 20-Feb-2019 Wed 27-Feb-2019 Wed 06-Mar-2019
Pass that in as the 2nd input to retime.