BuildSysPro.IBPSA.Utilities.Time.CalendarTime

# .BuildSysPro.IBPSA.Utilities.Time.CalendarTime

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

## 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 IBPSA.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==IBPSA.Utilities.Time.Types.ZeroTime.Custom`, the parameter `yearRef`. When `zerTim==IBPSA.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 IBPSA.BoundaryConditions.WeatherData.ReaderTMY3, as the weather data files used with this reader are generally defined with `time` being local time. If `zerTim==IBPSA.Utilities.Time.Types.ZeroTime.UnixTimeStampGMT` is used, then the weather data files read by IBPSA.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 2030 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-2030 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-2020 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 IBPSA.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.

## Revisions

- 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.

Generated at 2026-05-09T18:18:56Z by OpenModelicaOpenModelica 1.26.7 using GenerateDoc.mos