I need to use modular programming to return: Date (day and month), Time (24hr fo
ID: 643931 • Letter: I
Question
I need to use modular programming to return: Date (day and month), Time (24hr format), and the day of the week from a user input value in seconds.
An example output would be 23:01:01 8 March 2015 Tuesday
The start date is 00:00:00 1 January 2015
The trick is I cannot use Matlab functions to accomplish this...
Here is what I have so far...
%TimeCalc
%User will enter a time in seconds and TimeCalc will output the
%Seconds in a day = 86400
%Seconds in a week = 604800
%Seconds in a year = 31536000
%Seconds in a leap year = 31622400
%Initialize
clc
yr=31536000;
d=86400;
wk=604800;
startyear = 2015;
startdate = 1/1;
starttime = 00:00:00;
%Get user input in seconds
secs = input('Enter elapsed time in seconds: ');
%Calculate year
year = floor((secs/yr))+startyear;
%Determine if leap year
function[status] = leapyear(year)
if mod(year,4) == 0
status=true;
if mod(year,100) == 0
status=false;
if mod(year,400)==0
status=true;
end
end
else
status=false;
end
%Calculate month