- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » convert time to hour and minutes
convert time to hour and minutes
convert time to hour and minutes
Hi everybody I am quiet new from OpenModelica and I have several issue.
I am trying to convert the time for obtaining the corresponding in hour and minutes, but I don't how to write in the code for count until 59 minutes and when reach 60 add an hour and restart minutes from 00. This is the code:
model fromTimetoHour
Real min;
Real hour;
equation
min = div(time, 60);
hour = div(time, 3600);
end fromTimetoHour
If i set in the simulation the end time at 31536000 (second in one year) and with this code I obtain the total hours and minutes of the whole year.
But my aim is trying to have the classic visualization in hh:mm
someone can help me?
Re: convert time to hour and minutes
Real second = mod(time, 60);
Real minute = mod(div(time, 60), 60);
Real hour = mod(div(time, 3600), 24);
Real days = div(time, 3600*24);
- sjoelund.se
- 1700 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » convert time to hour and minutes