modelCalendarTime

Computes the unix time stamp and calendar time from the simulation time

Information

Block that outputs minute, hour, day of the month, month, year and weekday.

Assumption and limitations

The implementation only supports date computations from year 2010 up to and including 2020. Daylight saving and time zones are not supported.

Typical use and important parameters

The user must define which time and date correspond to time = 0 using the model parameters zerTim, and, if zerTim == CDL.Types.ZeroTime.Custom, the parameter yearRef. The user can choose from new year, midnight for a number of years: 2010 to 2020 and also 1970. The latter corresponds to a unix stamp of 0. Note that when choosing the reference time equal to 0 at 1970, the actual simulation time must be within the 2010-2020 range. For example, startTime = 1262304000 corresponds to the simulation starting on the 1st of January 2010 local time when setting zerTim = CDL.Types.ZeroTime.UnixTimeStamp. This is within the 2010-2020 range and is therefore allowed.

Parameters

TypeNameDefaultDescription
Buildings.Controls.OBC.CDL.Types.ZeroTimezerTimEnumeration for choosing how reference time (time = 0) should be defined
IntegeryearRef2016Year when time = 0, used if zerTim=Custom
Advanced
Realoffset0Offset that is added to 'time', may be used for computing time in different time zone

Connectors

TypeNameDefaultDescription
Buildings.Controls.OBC.CDL.Interfaces.IntegerOutputyearYear
Buildings.Controls.OBC.CDL.Interfaces.IntegerOutputmonthMonth of the year
Buildings.Controls.OBC.CDL.Interfaces.IntegerOutputdayDay of the month
Buildings.Controls.OBC.CDL.Interfaces.IntegerOutputhourHour of the day
Buildings.Controls.OBC.CDL.Interfaces.RealOutputminuteMinute of the hour
Buildings.Controls.OBC.CDL.Interfaces.IntegerOutputweekDayInteger output representing week day (monday = 1, sunday = 7)

Revisions

  • March 30, 2022, by Michael Wetter:
    Increased value of lastYear as the underlying implementation allows for 21 years.
  • November 12, 2020, by Michael Wetter:
    Reformulated to remove dependency to Modelica.Units.SI.
    This is for Buildings, issue 2243.
  • March 2, 2020, by Michael Wetter:
    Changed icon to display dynamically the output value.
  • August 20, 2019, by Filip Jorissen:
    Revised implementation such that the meaning of time is better explained and unix time stamps are correctly defined with respect to GMT. (see Buildings, issue 1192).
  • March 14, 2017, by Michael Wetter:
    Refactored implementation.
  • February 23, 2017, by Milica Grahovac:
    First CDL implementation.
  • August 3, 2016, by Filip Jorissen:
    First implementation.