-
Notifications
You must be signed in to change notification settings - Fork 3
/
when.m
33 lines (31 loc) · 767 Bytes
/
when.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
%% A simple function that returns a string of the current date and time.
% Useful for logging in script files.
%
%
% ARGUMENTS:
% none
%
% OUTPUT:
% date_and_time -- a string
%
% REQUIRES:
% none
%
% USAGE:
%{
%For logging of scripts, for example:
disp(['Script started: ' when()])
%Then do some stuff, before:
disp(['Script ended: ' when()])
%}
%
function date_and_time = when()
CurrentTime = clock;
Year = num2str(CurrentTime(1));
Month = num2str(CurrentTime(2));
Day = num2str(CurrentTime(3));
Hour = num2str(CurrentTime(4));
Minute = num2str(CurrentTime(5));
Second = num2str(CurrentTime(6));
date_and_time = [Year '-' Month '-' Day ' at ' Hour ':' Minute ':' Second];
end %function when()