Cody

# Problem 43612. time of day

Solution 2034937

Submitted on 25 Nov 2019 by Jean-Marie Sainthillier
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)

ans = 2000 1 12 0 6 16 ans = 3.7600e+11

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)

ans = 2000 1 12 0 6 16 ans = 0.1044

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)

ans = 1911 11 11 11 11 11 ans = 40271

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)

ans = 1911 11 11 11 11 11 ans = 0.4661

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

ans = 2016 10 24 20 26 28 ans = 7.3588e+13 ans = 2016 10 24 20 26 28 ans = 7.3588e+10 ans = 2016 10 24 20 26 28 ans = 73588000 ans = 2016 10 24 20 26 28 ans = 73588 ans = 2016 10 24 20 26 28 ans = 1.2265e+03 ans = 2016 10 24 20 26 28 ans = 20.4411 ans = 2016 10 24 20 26 28 ans = 0.8517