From GridLAB-D Wiki
Jump to: navigation, search

timestamp - Timestamp property

Synposis

C/C++
typedef int64 TIMESTAMP;
GLM
timestamp property-name;

Description

The timestamp property is a built-in data type that represents dates and times. Values are stored, computed and compared internally in UTC, but the timestamp implementation in the core can handle timezones listed in the runtime support file tzinfo.txt that is installed on host systems by GridLAB-D.

Timestamps are always of the form

YYYY-MM-DD hh:mm:ss ZZZ

where YYYY is the year (1970-2999), MM is the month (01-12), DD is the day (01-31), hh is the hours (00-23), mm is the minutes (00-59), ss is the seconds (00-59), and ZZZ is the timezone.

There are three constant timestamp values that are used to indicate special conditions.

INIT

The special timestamp value INIT is used to indicate that the timestamp has not established yet. This value is typically associated with a clock that has started yet. All valid timestamp values are greater than INIT time.

NEVER

The special timestamp value NEVER is used to indicate a time that is so far in the future that from the perspective of the simulation it should be treated as never expected to arrive. All valid timestamp values are less than than NEVER time.

INVALID

The special timestamp value INVALID is used to indicate an erroneous or invalid time was used. The value of INVALID is -1.

GLM

In GLM files a timestamp property may be added to a class using the syntax:

class my_class {
  timestamp my_datetime;
}

and an object may set a timestamp using the syntax:

object my_class {
  my_datetime 'YYYY-MM-DD hh:mm:ss ZZZ';
}

ASCII formatting

The format of timestamp values is controlled by the dateformat global variable.

Example

This example adds a timestamp variable named my_date to the climate class, defines a two climate objects, and sets their my_date values.

module climate;
class climate {
  timestamp my_date;
}
object climate {
  my_date '2010-04-17 12:31:47 PDT';
}
object climate {
  my_date NEVER;
}

See also