Skip to content

Commit

Permalink
fix(time) - Modify time module tests to remove dependency on current …
Browse files Browse the repository at this point in the history
…year
  • Loading branch information
Nelson-numerical-software committed Jan 1, 2025
1 parent 539b246 commit c565647
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
33 changes: 22 additions & 11 deletions modules/time/tests/test_datenum_string.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@
%=============================================================================
R = datevec(datenum('01/31','mm/dd'));
REF = [ 2024 1 31 0 0 0];
assert_isequal(R, REF);
assert_isequal(R(2:end), REF(2:end));
assert_istrue(R(1) >= 2024);
%=============================================================================
R = datevec(datenum('01/31','mm/dd', 100));
REF = [2024 1 31 0 0 0];
assert_isequal(R, REF);
assert_isequal(R(2:end), REF(2:end));
assert_istrue(R(1) >= 2024);
%=============================================================================
R = datevec(datenum('01/31/2009', 'mm/dd/yyyy'));
REF = [2009 1 31 0 0 0];
Expand Down Expand Up @@ -308,27 +310,33 @@
%=============================================================================
R = datevec(datenum('13:56:23', 'HH:MM:SS'));
REF = [ 2024 1 1 13 56 23];
assert_isequal(R, REF);
assert_isequal(R(2:end), REF(2:end));
assert_istrue(R(1) >= 2024);
%=============================================================================
R = datevec(datenum('13:56:23', 'HH:MM:SS', 100));
REF = [ 2024 1 1 13 56 23];
assert_isequal(R, REF);
assert_isequal(R(2:end), REF(2:end));
assert_istrue(R(1) >= 2024);
%=============================================================================
R = datevec(datenum('13:56', 'HH:MM'));
REF = [ 2024 1 1 13 56 0];
assert_isequal(R, REF);
assert_isequal(R(2:end), REF(2:end));
assert_istrue(R(1) >= 2024);
%=============================================================================
R = datevec(datenum('13:56', 'HH:MM', 100));
REF = [ 2024 1 1 13 56 0];
assert_isequal(R, REF);
assert_isequal(R(2:end), REF(2:end));
assert_istrue(R(1) >= 2024);
%=============================================================================
R = datevec(datenum("13:56:23 PM", "HH:MM:SS PM"));
REF = [2024 1 2 1 56 23];
assert_isequal(R, REF);
assert_isequal(R(2:end), REF(2:end));
assert_istrue(R(1) >= 2024);
%=============================================================================
R = datevec(datenum("13:56:23 PM", "HH:MM:SS PM", 100));
REF = [2024 1 2 1 56 23];
assert_isequal(R, REF);
assert_isequal(R(2:end), REF(2:end));
assert_istrue(R(1) >= 2024);
%=============================================================================
assert_checkerror('datenum("13:56:23", "HH:MM:SS PM")', _('Failed to convert text to date number.'));
%=============================================================================
Expand All @@ -338,15 +346,18 @@
%=============================================================================
R = datevec(datenum('13:56 AM', 'HH:MM AM'));
REF = [ 2024 1 1 13 56 0];
assert_isequal(R, REF);
assert_isequal(R(2:end), REF(2:end));
assert_istrue(R(1) >= 2024);
%=============================================================================
R = datevec(datenum('13:56 PM', 'HH:MM PM'));
REF = [ 2024 1 2 1 56 0];
assert_isequal(R, REF);
assert_isequal(R(2:end), REF(2:end));
assert_istrue(R(1) >= 2024);
%=============================================================================
R = datevec(datenum('13:56 PM', 'HH:MM PM', 100));
REF = [ 2024 1 2 1 56 0];
assert_isequal(R, REF);
assert_isequal(R(2:end), REF(2:end));
assert_istrue(R(1) >= 2024);
%=============================================================================
R = datevec(datenum('jan.012009', 'mmm.ddyyyy'));
REF = [ 2009 1 1 0 0 0];
Expand Down
10 changes: 7 additions & 3 deletions modules/time/tests/test_datestr_string.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@
% SPDX-License-Identifier: LGPL-3.0-or-later
% LICENCE_BLOCK_END
%=============================================================================
current_date=datevec(now());
%=============================================================================
R = datestr('05:32');
REF = '01-Jan-2024 05:32:00';
REF = sprintf('01-Jan-%d 05:32:00', current_date(1));
assert_isequal(R, REF);
%=============================================================================
R = datestr(["05:32","05:35"]);
REF = ['01-Jan-2024 05:32:00';'01-Jan-2024 05:35:00'];
REF1 = sprintf('01-Jan-%d 05:32:00', current_date(1));
REF2 = sprintf('01-Jan-%d 05:35:00', current_date(1));
REF = [REF1;REF2];
assert_isequal(R, REF);
%=============================================================================
R = datestr({'05:32', '05:35'});
REF = ['01-Jan-2024 05:32:00';'01-Jan-2024 05:35:00'];
REF = [REF1;REF2];
assert_isequal(R, REF);
%=============================================================================
R = datestr('05:32 PM','HH:MM');
Expand Down

0 comments on commit c565647

Please sign in to comment.