DL Logo

ASTimeSpan Typedefs

ASTimeSpan

Header: ASExpT.h:4081

Description

An ASTimeSpan represents an exact time span, measured in seconds. The internal representation uses 64-bit signed integers to avoid the year 2037 problem. Negative timespans are allowed.

Syntax

typedef struct _t_ASTimeSpanRec *ASTimeSpan;

Returned From

Used By

ASTimeSpan Functions

ASGetSecs

Header: ASProcs.h:1968

Description

Returns the number of seconds elapsed since midnight, January 1, 1970, coordinated universal time, up to the current time.

Syntax

ASCount ASGetSecs(void);

Returns

See above.

ASTimeSpanAdd

Header: ASExtraProcs.h:2012

Description

Adds two time spans, storing the result (an exact number of seconds) in another time span object.

Syntax

void ASTimeSpanAdd(const ASTimeSpan timeSpan1, const ASTimeSpan timeSpan2, ASTimeSpan result);

Parameters

timeSpan1
The first time span to add.
timeSpan2
The second time span to add.
result
The time span object in which to store the result.

ASTimeSpanCompare

Header: ASExtraProcs.h:1974

Description

Compares two time spans to determine if they are equal or if one represents fewer seconds than the other.

Syntax

ASInt32 ASTimeSpanCompare(const ASTimeSpan timeSpan1, const ASTimeSpan timeSpan2);

Parameters

timeSpan1
The first time span.
timeSpan2
The second time span.

Returns

1 if timeSpan1 > timeSpan2, 0 if they are equal, and-1 if timeSpan1 < timeSpan2.

ASTimeSpanCopy

Header: ASExtraProcs.h:1721

Description

Copies data from one time span object to another.

Related Methods

Syntax

void ASTimeSpanCopy(const ASTimeSpan original, ASTimeSpan copy);

Parameters

original
The time span to be copied.
copy
The time span into which the data is copied.

ASTimeSpanDestroy

Header: ASExtraProcs.h:1730

Description

Releases and destroys a time span object.

Syntax

void ASTimeSpanDestroy(ASTimeSpan timeSpan);

Parameters

timeSpan
The time span.

ASTimeSpanDiff

Header: ASExtraProcs.h:2052

Description

Calculates the exact difference in seconds between time span objects and stores the result in the provided ASTimeSpan object. If timeSpan2 is less than timeSpan1, the result is negative.

Syntax

void ASTimeSpanDiff(const ASTimeSpan timeSpan1, const ASTimeSpan timeSpan2, ASTimeSpan result);

Parameters

timeSpan1
The first time span.
timeSpan2
The second time span.
result
The time span object in which to store the difference.

ASTimeSpanDup

Header: ASExtraProcs.h:1712

Description

Creates a new time span object containing the same data as an existing time span object. It raises an exception if there is not enough memory.

Syntax

ASTimeSpan ASTimeSpanDup(const ASTimeSpan timeSpan);

Parameters

timeSpan
The time span to duplicate.

Returns

The new time span object.

ASTimeSpanGetASInt32

Header: ASExtraProcs.h:2367

Description

Gets the number of seconds from a time span object.

Syntax

ASInt32 ASTimeSpanGetASInt32(ASTimeSpan timeSpan, ASBool *outOverflow);

Parameters

timeSpan
The time span object.
outOverflow
(Filled by the method) true if the number of seconds was too large to be represented by an ASInt32 value, false otherwise.

Returns

The number of seconds.

ASTimeSpanNegate

Header: ASExtraProcs.h:2288

Description

Negates the time span value of a time span object.

Syntax

void ASTimeSpanNegate(ASTimeSpan timeSpan);

Parameters

timeSpan
The time span.

ASTimeSpanNew

Header: ASExtraProcs.h:1699

Description

Creates a time span object. It raises an exception if there is not enough memory for the operation.

Syntax

ASTimeSpan ASTimeSpanNew(void);

Returns

The newly created time span object.

ASTimeSpanSet

Header: ASExtraProcs.h:2112

Description

The internal representation of a time span uses 64-bit signed integers (to avoid the year 2038 problem caused by 32-bit representation). This method initializes a time span object to represent a time span of x seconds, where x is the 64-bit signed integer obtained from concatenating highBits and lowBits.

Syntax

void ASTimeSpanSet(ASTimeSpan timeSpan, ASInt32 highBits, ASUns32 lowBits);

Parameters

timeSpan
The time span object.
highBits
The most significant word in the desired 64-bit signed integer value.
lowBits
The least significant word in the desired 64-bit signed integer value.

ASTimeSpanSetFromASInt32

Header: ASExtraProcs.h:2078

Description

Initializes a time span object to represent a time span of a specific number of seconds.

Syntax

void ASTimeSpanSetFromASInt32(ASTimeSpan timeSpan, ASInt32 numSeconds);

Parameters

timeSpan
The time span object.
numSeconds
The number of seconds.

ASTimeSpanSetFromString

Header: ASExtraProcs.h:2094

Description

Converts a string to a number of seconds, and initializes a time span object to represent a time span of that number of seconds. This is useful for time spans that are too long to represent with an ASInt32 value.

Syntax

void ASTimeSpanSetFromString(ASTimeSpan timeSpan, const char *numSecondsString);

Parameters

timeSpan
The time span object.
numSecondsString
The string containing the number of seconds. The string must consist of an optional minus sign (for negative numbers) followed by decimal digits. No white spaces are allowed anywhere in the string.