Unverified Commit d09fbec8 authored by stephen scott tucker's avatar stephen scott tucker Committed by GitHub
Browse files

datetime exceptions raised by some OS should be caught safely (#63)

parent 897c409d
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -391,6 +391,7 @@ classdef FuncRegClass < matlab.mixin.Copyable
        
        % ----------------------------------------------------------------------------------
        function lastdt = DateLastModified(obj)
            try
                lastdt = datetime(1970,01,01);
                for ii = 1:length(obj.entries)
                    for jj = 1:length(obj.userfuncdir)
@@ -403,6 +404,9 @@ classdef FuncRegClass < matlab.mixin.Copyable
                        end
                    end
                end
            catch
                lastdt = -1;
            end
        end
        
    end
+6 −2
Original line number Diff line number Diff line
@@ -362,9 +362,13 @@ classdef RegistriesClass < handle
            b = false;
            regfile = dir([obj.userfuncdir{1}, 'Registry.mat']);
            for ii = 1:length(obj.funcReg)
                try
                    if obj.funcReg(ii).DateLastModified() > datetime(regfile.date,'locale','system')
                        return;
                    end
                catch
                    % pass
                end
            end
            b = true;
        end
+5 −1
Original line number Diff line number Diff line
function dt = GetLastCheckForUpdates()
if ~ispathvalid([getAppDir, 'LastCheckForUpdates.dat'])
    try
        dt = datetime - duration(200,0,0);
    catch
        dt = -1;
    end
else
    fd = fopen([getAppDir, 'LastCheckForUpdates.dat'],'rt');
    dt = fgetl(fd);
+10 −2
Original line number Diff line number Diff line
@@ -154,7 +154,11 @@ classdef Logger < handle
            if options == self.options.NULL
                return
            end
            try
                ct = char(datetime(datetime, 'Format','MMMM d, yyyy, HH:mm:ss'));
            catch
                ct = "";
            end
            if isempty(msg)
                s = sprintf('\n%s\n', ct);
            else
@@ -195,7 +199,11 @@ classdef Logger < handle
            if options == self.options.NULL
                return
            end
            try
                ct = char(datetime(datetime, 'Format','MMMM d, yyyy, HH:mm:ss'));
            catch
                ct = "";
            end
            s =  sprintf('\n%s:  %s', ct, msg);
            
            if bitand(options, self.options.FILE_ONLY) > 0
+5 −1
Original line number Diff line number Diff line
@@ -3,7 +3,11 @@ if ~exist('dt','var') && ispathvalid([getAppDir, 'LastCheckForUpdates.dat'])
    return;
end
if ~exist('dt','var')
    try
        dt = datetime;
    catch
        dt = -1;
    end
end
fd = fopen([getAppDir, 'LastCheckForUpdates.dat'],'wt');
fprintf(fd, '%s\n', dt);
Loading