Class ElapsedTime

Introduction

This class provides an elapsed time clock.

Contents

  1. Introduction
  2. Contents
  3. Explanation of symbols used
  4. Member reference
    1. (constructor) - start an elapsed timer
    2. datetime_struct - structure of the result of %datetime
    3. nSeconds - number of seconds since StartTime
    4. Overhead - number of seconds to omit
    5. reset - reset the start time
    6. StartTime - the starting time for this timer
    7. ToString - string representation of the elapsed time

Explanation of symbols used

Words in italics indicate an instance of a class. The word corresponds to the class name, except where more than one instance is represented in the same statement. In that case a number (2, 3, etc.) is appended to the class name.

Words in normal typeface are to be taken literally (required punctuation, class name in a static reference, method name, etc.)

The symbol => is used to separate an expression (on the left) from its return value (on the right).

An ellipsis (...) indicates that the previous argument may be repeated any number of times. The description will indicate whether one instance is required.

Member reference

constructor

new ElapsedTime() => elapsedtime
This creates a new ElapsedTime with StartTime set to the current time, and Overhead set to 0.

structure datetime_struct


    public structure datetime_struct
        group date, d8		;Date portion
            yyyy,d4		;Year with century
            mm  ,d2		;Month
            dd  ,d2		;Day
        endgroup
        group tm, d9		;Time portion
            hr  ,d2		;Hour (0-23)
            min ,d2		;Minute
            sec ,d2		;Second
            msec,d3		;Millisecond
        endgroup
    endstructure
    
This structure is used internally by ElapsedTime, and also as the value of the StartTime property. You can fill this structure with the current date and time by assigning it the result of %datetime.

property nSeconds

elapsedtime.nSeconds => decimal
This read-only property yields the number of seconds elapsed, which is the difference between the current time and StartTime, minus Overhead.

property Overhead

elapsedtime.Overhead => decimal
elapsedtime.Overhead = decimal
This property is the number of seconds to omit from the result of nSeconds or ToString().

method reset

elapsedtime.reset()
Resets StartTime to the current time.

property StartTime

elapsedtime.StartTime => datetime_struct
elapsedtime.StartTime = datetime_struct
This property represents the date and time used as the starting time for computing the elapsed time.

override method ToString

elapsedtime.ToString() => string

This method returns a string representation of the elapsed time since StartTime, minus Overhead, as follows:

If the elapsed time is less than 24 hours, the result is "HH:MM:SS.mmm", where HH is the number of hours, MM is the number of minutes, SS is the number of seconds, and mmm is the number of milliseconds.

If the elapsed time is 24 hours or more, then the number of whole days is returned as either "1 day + " or "N days + " (where N is the number of days) followed by the remainder formatted as above for less than 24 hours.