Next: , Previous: , Up: srfi time spec   [Index]


2.11.3.4 Time object

Time object and accessors

The following procedures are required:

Function: make-time time-type nanosecond second

Return a new time object.

Function: time? obj

Return #t if obj is a time object; otherwise return #f.

Function: time-type time

Return the Time type symbol of time. srfi time spec intro for details.

Function: time-nanosecond time

Return the Nanosecond component of time.

Function: time-second time

Return the Second component of time.

Function: set-time-type! time time-type

Set the Time type component of time to time-type, which must be one of the time type symbols. srfi time spec intro for details.

NOTE This changes the semantics of the time object. To convert a time to another system of representation, use one of the conversion procedures.

Function: set-time-nanosecond! time integer

Set the Nanosecond component of time to integer.

Function: set-time-second! time integer

Set the Second component of time to integer.

Function: copy-time time

Create a new time object, with the same Time type, nanosecond, and Second as time.

Time object comparison procedures

All of the time comparison procedures require the time objects to be of the same type. It is an error to use these procedures on time objects of different types. For the point–in–time measurements (e.g. time-tai and time-utc), the semantics are described in plain text. For durations (e.g. time-duration, time-cpu) the semantics are described in parentheses.

The following procedures are required.

Function: time<=? time1 time2

Return #t if time1 is before or at (less than or equal to) time2, #f otherwise.

Function: time<? time1 time2

Return #t if time1 is before (less than) time2, #f otherwise.

Function: time=? time1 time2

Return #t if time1 at (equal) time2, #f otherwise.

Function: time>=? time1 time2

Return #t if time1 is at or after (greater than or equal to) time2, #f otherwise.

Function: time>? time1 time2

Return #t if time1 is after (greater than) time2, #f otherwise.

Time object arithmetic procedures

The following procedures are required.

Function: time-difference time1 time2

Return a new time object of type time-duration representing the time duration between time1 and time2. It is an error if time1 and time2 are of different time types.

Function: time-difference! time1 time2

Compute the time duration between time1 and time2; mutate time1 to represent the computed time as a time-duration object. It is an error if time1 and time2 are of different time types.

Function: add-duration time duration

Return a new time object, of type equal to the type of time1, representing the result of adding duration to time. duration must be a time object of type time-duration.

Function: add-duration! time duration

Mutate time to represent the result of adding duration to time. duration must be a time object of type time-duration.

Function: subtract-duration time duration

Return a new time object, of the same type of time, representing the result of subtracting duration from time. duration must be a time object of type time-duration.

Function: subtract-duration! time duration

Mutate time to represent the result of subtracting duration from time. duration must be a time object of type time-duration.


Next: , Previous: , Up: srfi time spec   [Index]