How can I print the current date and/or time to a file (e.g. log file, or csv file) from Modelica? Do I need external code for this? I was not able to find any example code in the Modelica Standard Library.
https://build.openmodelica.org/Documentation/Modelica.Utilities.Streams.print.html
You would need to add this to your equation or algorithm section:
.Modelica.Utilities.Streams.print(String(time));
For local system time use: https://build.openmodelica.org/Documentation/Modelica.Utilities.System.getTime.html
model GetTime
Integer ms;
Integer sec;
Integer min;
Integer hour;
Integer mday;
Integer mon;
Integer year;
algorithm
(ms, sec, min, hour, mday, mon, year) := .Modelica.Utilities.System.getTime();
.Modelica.Utilities.Streams.print("ms:" + String(ms) + "\n");
.Modelica.Utilities.Streams.print("sec:" + String(sec) + "\n");
.Modelica.Utilities.Streams.print("min:" + String(min) + "\n");
.Modelica.Utilities.Streams.print("hour:" + String(hour) + "\n");
.Modelica.Utilities.Streams.print("mday:" + String(mday) + "\n");
.Modelica.Utilities.Streams.print("mon:" + String(mon) + "\n");
.Modelica.Utilities.Streams.print("year:" + String(year) + "\n");
end GetTime;