Cody

Solution 1728852

Submitted on 17 Feb 2019 by Alfonso Nieto-Castanon
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x = '12-Jan-2000 00:06:16'; y_correct = 376 * 1e9; units = 'nanoseconds'; assert(abs(timeOfDay(x, units) - y_correct) / y_correct < 1e-3)

2   Pass
x = '12-Jan-2000 00:06:16'; y_correct = 0.10444444; units = 'hours'; assert(abs(timeOfDay(x, units) - y_correct) / y_correct < 1e-3)

3   Pass
x = '11-Nov-1911 11:11:11'; y_correct = 40271; units = 'seconds'; assert(abs(timeOfDay(x, units) - y_correct) / y_correct < 1e-3)

4   Pass
x = '11-Nov-1911 11:11:11'; y_correct = 0.4660995; units = 'days'; assert(abs(timeOfDay(x, units) - y_correct) / y_correct < 1e-3)

5   Pass
x = '24-Oct-2016 20:26:28'; y_correct = [73588*1e9 73588*1e6 73588000 ... 73588 1226.4667 20.441111 0.85171296]; units = {'nanoseconds', 'microseconds', 'milliseconds',... 'seconds', 'minutes', 'hours', 'days'}; for i = 1:numel(y_correct) assert(abs(timeOfDay(x, units{i}) - y_correct(i)) / y_correct(i) < 1e-3) end