modelCalendarTime

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

Extends from Modelica.Blocks.Icons.DiscreteBlock (Graphical layout of discrete block component icon).

Information

This blocks computes the unix time stamp, date and time and the day of the week based on the Modelica variable time. As for the weather data reader Buildings.BoundaryConditions.WeatherData.ReaderTMY3, time=0 corresponds to January 1st at midnight in the local time zone. The computed outputs are thus also for the local time zone. The year for which time=0 is determined by the parameter zerTim.

Main equations

The unix time stamp corresponding to the current time is computed. From this variables the corresponding, year, date and time are computed using functions such as floor() and ceil().

Assumption and limitations

The implementation only supports date computations from year 2010 up to and including 2020. Daylight saving is 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==Buildings.Utilities.Time.Types.ZeroTime.Custom, the parameter yearRef. When zerTim==Buildings.Utilities.Time.Types.ZeroTime.UnixTimeStampGMT, time is defined with respect to GMT. This is different from the use of time in the weather data reader Buildings.BoundaryConditions.WeatherData.ReaderTMY3, as the weather data files used with this reader are generally defined with time being local time. If zerTim==Buildings.Utilities.Time.Types.ZeroTime.UnixTimeStampGMT is used, then the weather data files read by Buildings.BoundaryConditions.WeatherData.ReaderTMY3 must also be defined with GMT as the time stamp. The user can choose from new year, midnight for a number of years: 2010 to 2050 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-2051 range. For instance startTime = 1262304000 corresponds to the simulation starting on the 1st of January 2010 when setting zerTim = ZeroTime.UnixTimeStamp. This is within the 2010-2050 range and is therefore allowed.) The unix time stamp is formally defined as the number of seconds since midnight of new year in 1970 GMT. To output the correct unix time stamp, set outputUnixTimeStamp=true We then require the local time zone timZon (see Buildings.BoundaryConditions.WeatherData.ReaderTMY3) since time uses the local time zone instead of GMT. We always output unixTimeStampLocal, which is a time stamp that uses the local time zone reference instead of GMT.

Implementation

The model was implemented such that no events are being generated for computing the minute of the day. The model also contains an implementation for setting time=0 for any day and month other than January first. This is however not activated in the current model since these options may wrongly give the impression that it changes the time based on which the solar position is computed and TMY3 data are read.

Parameters

TypeNameDefaultDescription
Buildings.Utilities.Time.Types.ZeroTimezerTimEnumeration for choosing how reference time (time = 0) should be defined
IntegeryearRef2016Year when time = 0, used if zerTim=Custom
Unix time stamp
BooleanoutputUnixTimeStampfalse= true, to output the unix time stamp (using GMT reference)
Modelica.Units.SI.TimetimZon0The local time zone, for computing the unix time stamp only
Advanced
Modelica.Units.SI.Timeoffset0Offset that is added to 'time', may be used for computing time in different time zones

Connectors

TypeNameDefaultDescription
Modelica.Blocks.Interfaces.RealOutputunixTimeStampLocalUnix time stamp at local time
Modelica.Blocks.Interfaces.RealOutputunixTimeStampunixTimeStampLocal - timZonUnix time stamp
Modelica.Blocks.Interfaces.IntegerOutputyearYear
Modelica.Blocks.Interfaces.IntegerOutputmonthMonth of the year
Modelica.Blocks.Interfaces.IntegerOutputdayDay of the month
Modelica.Blocks.Interfaces.IntegerOutputhourHour of the day
Modelica.Blocks.Interfaces.RealOutputminuteMinute of the hour
Modelica.Blocks.Interfaces.IntegerOutputweekDayInteger output representing week day (monday = 1, sunday = 7)

Revisions

  • March 8, 2024, by Jelger Jansen:
    Allow reference years later than 2020 and extend functionality to year 2050.
    This is for #1847.
  • December 19, 2022, by Michael Wetter:
    Refactored implementation to avoid wrong day number due to rounding errors that caused simultaneous events to not be triggered at the same time.
    This is for Buildings, #3199.
  • November 6, 2019, by Milica Grahovac:
    Extended functionality to year 2030.
  • 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 #1192).
  • February 14, 2019, by Damien Picard:
    Fix bug when non-zero offset by substracting the offset from hourSampleStart and daySampleStart (see #1099).
  • August 3, 2016, by Filip Jorissen:
    First implementation.