A common requirement in programs is getting the number of seconds, milliseconds, or nanoseconds since the Unix epoch. Here’s how to do it in Modelica.
In Modelica, we don’t have direct equivalents for all the time-related functions available in some other languages. However, we can use the System.getTime() function to get the current time in seconds since the epoch.
To run this model:
Note that Modelica doesn’t provide built-in functions for millisecond or nanosecond precision, so we’re calculating these values manually. Also, there’s no direct equivalent to converting integer seconds or nanoseconds back to a time object, so we’re just demonstrating getting the current time again.
Next, we’ll look at another time-related task: time formatting and parsing, which may require additional libraries or external functions in Modelica.