Skip to content

Commit 4d82b6b

Browse files
committed
more tolerent readnodeevent.m to dates
1 parent fd992cc commit 4d82b6b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

CODE/matlab/isodatenum.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@
77
% YYYY-MM-DD
88
% YYYY-MM-DD hh:mm:ss
99
%
10+
% ISODATENUM is tolerent to weird separator character (all but numerical).
11+
%
1012
% Author: F. Beauducel, IPGP
1113
% Created: 2009-10-19
12-
% Updated: 2014-11-14
14+
% Updated: 2022-06-13
1315

1416
if ~iscell(dt)
1517
dt = cellstr(dt);
1618
end
1719

1820
x = nan(size(dt));
19-
k = find(~isempty(dt) & ~strcmp(dt,'NA'));
21+
k = find(~strcmp(dt,'') & ~strcmp(dt,'NA'));
2022
for kk = 1:length(k)
21-
tmp = textscan(dt{k(kk)},'%s','Delimiter','-: ');
22-
v = str2double(tmp{:});
23+
v = str2num(regexprep(dt{k(kk)},'[^0-9]',' '));
2324
% completes cell array to match 6-column (necessary for DATENUM exigences)
2425
l = length(v);
2526
dv = [0,1,1,0,0,0];

CODE/matlab/readnodeevent.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
ss = split(fileread(file),'\n');
2727
% event header = authors|title|datetime2|feature|sensor|outcome|notebook|notebookfwd
2828
evthead = split(ss{1},'|');
29+
X.date2 = X.date1;
2930
if length(evthead) > 2
30-
X.date2 = isodatenum(evthead{3});
31-
else
32-
X.date2 = X.date1;
31+
date2 = isodatenum(evthead{3});
32+
if ~isnan(date2)
33+
X.date2 = date2;
34+
end
3335
end
3436
if length(evthead) > 0
3537
X.author = evthead{1};

0 commit comments

Comments
 (0)