Cody

# Problem 62. Elapsed Time

Solution 1893405

Submitted on 7 Aug 2019 by liu xinyang
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
d1 = '2010/12/14 12:00:00'; d2 = '2010/12/17 17:06:00'; elapsed = 77.1; assert(abs(elapsed_time(d1,d2) - elapsed) < 1e-6)

time1 = 1×6 cell array {'2010'} {'12'} {'14'} {'12'} {'00'} {'00'} time2 = 1×6 cell array {'2010'} {'12'} {'17'} {'17'} {'06'} {'00'} time = [] time = 2010 time = 2010 12 time = 2010 12 17 time = 2010 12 17 17 time = 2010 12 17 17 6 time = 2010 12 17 17 6 0 day = 0 day = 734487 day = 734503 hours = 1.7628e+07 time = [] time = 2010 time = 2010 12 time = 2010 12 14 time = 2010 12 14 12 time = 2010 12 14 12 0 time = 2010 12 14 12 0 0 day = 0 day = 734487 day = 734500 hours = 17628012 elapsed = 77.1000

2   Pass
d1 = '2010/12/14 12:00:00'; d2 = '2010/12/14 12:00:01'; elapsed = 1/3600; assert(abs(elapsed_time(d1,d2) - elapsed) < 1e-6)

time1 = 1×6 cell array {'2010'} {'12'} {'14'} {'12'} {'00'} {'00'} time2 = 1×6 cell array {'2010'} {'12'} {'14'} {'12'} {'00'} {'01'} time = [] time = 2010 time = 2010 12 time = 2010 12 14 time = 2010 12 14 12 time = 2010 12 14 12 0 time = 2010 12 14 12 0 1 day = 0 day = 734487 day = 734500 hours = 1.7628e+07 time = [] time = 2010 time = 2010 12 time = 2010 12 14 time = 2010 12 14 12 time = 2010 12 14 12 0 time = 2010 12 14 12 0 0 day = 0 day = 734487 day = 734500 hours = 17628012 elapsed = 2.7778e-04

3   Pass
d1 = '1924/1/7 12:45:00'; d2 = '2010/12/14 17:06:00'; elapsed = 762076.35; assert(abs(elapsed_time(d1,d2) - elapsed) < 1e-6)

time1 = 1×6 cell array {'1924'} {'1'} {'7'} {'12'} {'45'} {'00'} time2 = 1×6 cell array {'2010'} {'12'} {'14'} {'17'} {'06'} {'00'} time = [] time = 2010 time = 2010 12 time = 2010 12 14 time = 2010 12 14 17 time = 2010 12 14 17 6 time = 2010 12 14 17 6 0 day = 0 day = 734487 day = 734500 hours = 1.7628e+07 time = [] time = 1924 time = 1924 1 time = 1924 1 7 time = 1924 1 7 12 time = 1924 1 7 12 45 time = 1924 1 7 12 45 0 day = 0 day = 702741 day = 702747 hours = 1.6866e+07 elapsed = 7.6208e+05

4   Pass
d1 = '2010/12/14 12:00:00' d2 = '2010/12/14 13:06:36' elapsed = 1.11; assert(abs(elapsed_time(d1,d2) - elapsed) < 1e-6)

d1 = '2010/12/14 12:00:00' d2 = '2010/12/14 13:06:36' time1 = 1×6 cell array {'2010'} {'12'} {'14'} {'12'} {'00'} {'00'} time2 = 1×6 cell array {'2010'} {'12'} {'14'} {'13'} {'06'} {'36'} time = [] time = 2010 time = 2010 12 time = 2010 12 14 time = 2010 12 14 13 time = 2010 12 14 13 6 time = 2010 12 14 13 6 36 day = 0 day = 734487 day = 734500 hours = 1.7628e+07 time = [] time = 2010 time = 2010 12 time = 2010 12 14 time = 2010 12 14 12 time = 2010 12 14 12 0 time = 2010 12 14 12 0 0 day = 0 day = 734487 day = 734500 hours = 17628012 elapsed = 1.1100

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!