SUMMARY: MODULE | CLASS | TYPE | PROC | VAR | CONST | DETAIL: TYPE | PROC | VAR | CONST

# Time

### Import List

        SysClock

Class List
Interval | The Interval is a delta time measure which can be used to increment a TimeStamp or find the time difference between two TimeStamps.
TimeStamp | The TimeStamp is a compressed date/time format with the advantage over the Unix time stamp of being able to represent any date/time in the SysClock.DateTime type.

Class Summary: Interval [Detail]
      +--Time.Interval
The Interval is a delta time measure which can be used to increment a TimeStamp or find the time difference between two TimeStamps. The maximum number of milliseconds in an interval will be the value msecPerDay.
Field Summary
dayInt-: LONGINT Number of days in this interval.
msecInt-: LONGINT The number of milliseconds in this interval.
Constructor Summary
InitInterval(VAR Interval, LONGINT, LONGINT) Initialize the Interval int with days days and msecs mS.
Method Summary
Add(Interval)
Cmp(Interval): SHORTINT Compares a to b.
Fraction(Interval): LONGREAL
Scale(LONGREAL)
Sub(Interval)

Class Summary: TimeStamp [Detail]
      +--Time.TimeStamp
The TimeStamp is a compressed date/time format with the advantage over the Unix time stamp of being able to represent any date/time in the SysClock.DateTime type. Note: TimeStamp is in UTC or local time when time zones are not supported by the local operating system.
Field Summary
days-: LONGINT Modified Julian days since ``17 Nov 1858`'.
msecs-: LONGINT Milliseconds since ``00:00`'.
Constructor Summary
InitTimeStamp(VAR TimeStamp, LONGINT, LONGINT) Initialize the TimeStamp t with days days and msecs mS.
Method Summary
Add(Interval) Adds the interval b to the time stamp a.
Cmp(TimeStamp): SHORTINT Compares a to b.
Delta(TimeStamp, VAR Interval)
Sub(Interval) Subtracts the interval b from the time stamp a.

Procedure Summary
GetTime(VAR TimeStamp) Set t to the current time of day.

Constant Summary
msecPerDay Number of millseconds in a day.
msecPerHour Number of millseconds in an hour.
msecPerMin Number of millseconds in a minute.
msecPerSec Number of millseconds in a second.

Class Detail: Interval

Field Detail

### dayInt

    FIELD dayInt-: LONGINT

> Number of days in this interval.

### msecInt

    FIELD msecInt-: LONGINT

> The number of milliseconds in this interval. This number is from [0, msecPerDay[.

Constructor Detail

### InitInterval

    PROCEDURE InitInterval(VAR int: Interval;
                           days: LONGINT;
                           msecs: LONGINT)

> Initialize the Interval int with days days and msecs mS.

> Pre-condition: msecs>=0

Method Detail

### Add

    PROCEDURE (VAR a: Interval) Add(b: Interval)

> Post-condition: a = a + b

### Cmp

    PROCEDURE (VAR a: Interval) Cmp(b: Interval): SHORTINT

> Compares a to b. Result:

> -1 | a<b
> 0 | a=b
> 1 | a>b

> This means the comparison can be directly extrapolated to a comparison between the two numbers, for example,

> >     Cmp(a,b)<0  then a<b
> >     Cmp(a,b)=0  then a=b
> >     Cmp(a,b)>0  then a>b
> >     Cmp(a,b)>=0 then a>=b

### Fraction

    PROCEDURE (VAR a: Interval) Fraction(b: Interval): LONGREAL

> Pre-condition: b<>0

> Post-condition: RETURN a/b

### Scale

    PROCEDURE (VAR a: Interval) Scale(b: LONGREAL)

> Pre-condition: b>=0;

> Post-condition: a := a*b

### Sub

    PROCEDURE (VAR a: Interval) Sub(b: Interval)

> Post-condition: a = a - b

Class Detail: TimeStamp

Field Detail

### days

    FIELD days-: LONGINT

> Modified Julian days since ``17 Nov 1858`'. This quantity can be negative to represent dates occuring before day zero.

### msecs

    FIELD msecs-: LONGINT

> Milliseconds since ``00:00`'.

Constructor Detail

### InitTimeStamp

    PROCEDURE InitTimeStamp(VAR t: TimeStamp;
                            days: LONGINT;
                            msecs: LONGINT)

> Initialize the TimeStamp t with days days and msecs mS.

> Pre-condition: msecs>=0

Method Detail

### Add

    PROCEDURE (VAR a: TimeStamp) Add(b: Interval)

> Adds the interval b to the time stamp a.

### Cmp

    PROCEDURE (VAR a: TimeStamp) Cmp(b: TimeStamp): SHORTINT

> Compares a to b. Result:

> -1 | a<b
> 0 | a=b
> 1 | a>b

> This means the comparison can be directly extrapolated to a comparison between the two numbers, for example,

> >     Cmp(a,b)<0  then a<b
> >     Cmp(a,b)=0  then a=b
> >     Cmp(a,b)>0  then a>b
> >     Cmp(a,b)>=0 then a>=b

### Delta

    PROCEDURE (VAR a: TimeStamp) Delta(b: TimeStamp;
                    VAR c: Interval)

> Post-condition: c = a - b

### Sub

    PROCEDURE (VAR a: TimeStamp) Sub(b: Interval)

> Subtracts the interval b from the time stamp a.

Procedure Detail

### GetTime

    PROCEDURE GetTime(VAR t: TimeStamp)

> Set t to the current time of day. In case of failure (that is, if SysClock.CanGetClock() is FALSE) the time ``00:00 UTC`' on ``Jan 1 1970`' is returned. This procedure is typically much faster than doing SysClock.GetClock followed by Calendar.SetTimeStamp.

Constant Detail

### msecPerDay

    CONST msecPerDay

> Number of millseconds in a day.

### msecPerHour

    CONST msecPerHour

> Number of millseconds in an hour.

### msecPerMin

    CONST msecPerMin

> Number of millseconds in a minute.

### msecPerSec

    CONST msecPerSec

> Number of millseconds in a second.