DL Logo

ASDate Typedefs

ASDate

Header: ASExpT.h:4052

Description

An opaque object holding information for a particular date and time. All ASDate objects are guaranteed to give accurate representation of UTC time, unadjusted for leap seconds. This is due to the fact that the introduction of leap seconds to the international calendar does not happen according to a well-defined rule.

Note: ASDate objects are not guaranteed to represent local time accurately. To be exact, in Mac OS and UNIX, ASDate cannot always determine the prevailing daylight saving rule for the operating system's time zone. See ASDateGetCurrentLocalTime() for further explanation.

Syntax

typedef struct _t_ASDateRec *ASDate;

Returned From

Used By

ASDateTimeFormat

Header: ASExpT.h:4040

Description

A constant indicating a string format for representing a date and time. See PDF date formats, page 87. You can find this document on the web store of the International Standards Organization (ISO).

For value options see ASTimeOptions.

Syntax

typedef ASEnum8 ASDateTimeFormat;

Used By

ASDate Structures

_t_ASTimeRec

Header: ASExpT.h:1291

Description

A time/date structure.

The millisecond field is currently unused.

Syntax

struct _t_ASTimeRec {
ASInt16 year;
Only common era years are displayed appropriately.
ASInt16 month;
Jan = 1,..., Dec = 12.
ASInt16 date;
1..31
ASInt16 hour;
0..23
ASInt16 minute;
0..59
ASInt16 second;
0..59
ASInt16 millisecond;
0..999
ASInt16 day;
Sun = 0,... Sat = 6.
ASInt16 gmtOffset;
GMT offset in half hours east of Greenwich.-48 signifies an unknown value.
} ASTimeRec, *ASTimeRecP;

Returned From

Used By

Used In

ASDate Functions

ASDateAddCalendarTimeSpan

Header: ASExtraProcs.h:1837

Description

Adds a calendar time span to a date. It modifies the date by the length of time provided in the ASCalendarTimeSpan object.

Note: There is some ambiguity in a calendar time span; to add an exact time span (for example, 2592000 seconds rather than one month), use ASDateAddTimeSpan().

Syntax

void ASDateAddCalendarTimeSpan(ASDate date, const ASCalendarTimeSpan timeSpan);

Parameters

date
The date.
timeSpan
The calendar time span to add.

ASDateAddTimeSpan

Header: ASExtraProcs.h:1862

Description

Adds a time span (an exact number of seconds) to a date. It modifies the date by the length of time provided in the ASTimeSpan object.

Syntax

void ASDateAddTimeSpan(ASDate date, const ASTimeSpan timeSpan);

Parameters

date
The date.
timeSpan
The time span to add.

ASDateCalendarDiff

Header: ASExtraProcs.h:1878

Description

Calculates the difference between two ASDate objects and stores the result in the provided ASCalendarTimeSpan object. The result is broken down into years, months, and so on, in the highest denomination possible. For example, a difference of 13 months is reported as 1 year and 1 month.

Syntax

void ASDateCalendarDiff(const ASDate date1, const ASDate date2, ASCalendarTimeSpan result);

Parameters

date1
The first date.
date2
The second date.
result
The calendar time span structure in which to store the difference.

ASDateClear

Header: ASExtraProcs.h:1667

Description

Reinitializes a date object to the newly-allocated state, as returned by ASDateNew().

Related Methods

ASDateDestroy ASDateNew

Syntax

void ASDateClear(ASDate retVal);

Parameters

retVal
The date object.

ASDateCompare

Header: ASExtraProcs.h:2066

Description

Tests whether one date is earlier or later than another.

Syntax

ASInt32 ASDateCompare(const ASDate date1, const ASDate date2);

Parameters

date1
The first date.
date2
The second date.

Returns

1 if date1 > date2, 0 if they are equal,-1 if date1 < date2.

ASDateCopy

Header: ASExtraProcs.h:1678

Description

Copies date and time data from one date object to another.

Related Methods

ASDateClear ASDateDup

Syntax

void ASDateCopy(const ASDate original, ASDate copy);

Parameters

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

ASDateDestroy

Header: ASExtraProcs.h:1688

Description

Releases and destroys a date object.

Syntax

void ASDateDestroy(ASDate date);

Parameters

date
The date.

ASDateDup

Header: ASExtraProcs.h:1657

Description

Creates a new date object containing the same data as an existing date object.

Syntax

ASDate ASDateDup(const ASDate date);

Parameters

date
The date to duplicate.

Returns

The new date object.

ASDateExactDiff

Header: ASExtraProcs.h:1894

Description

Calculates the exact difference in seconds between two date objects and stores the result in the provided ASTimeSpan object. If date1 is earlier than date2, the result is negative.

Syntax

void ASDateExactDiff(const ASDate date1, const ASDate date2, ASTimeSpan result);

Parameters

date1
The first date.
date2
The second date.
result
The time span structure in which to store the difference.

ASDateGetLocalTime

Header: ASExtraProcs.h:1942

Description

Creates a time record that represents the local time represented by the date object. The resulting local time might not account for daylight savings time correctly if the date object has been modified by adding or substracting a time span or calendar time span. It raises an exception if there is not enough memory.

Syntax

ASTimeRec ASDateGetLocalTime(const ASDate date);

Parameters

date
The date.

Returns

The newly created time record.

ASDateGetTimeString

Header: ASExtraProcs.h:1913

Description

Creates a time string from a date object according to a specified format. If time zone information is available in the date object, the string contains the local time along with the time zone adjustment, if that is supported by the requested format. It raises an exception if there is not enough memory.

It is the client's responsibility to release the memory associated with the returned string using ASfree().

Syntax

char *ASDateGetTimeString(const ASDate date, ASDateTimeFormat format);

Parameters

date
The date object.
format
The format of the time string.

Returns

The time string in the specified format.

ASDateGetUTCTime

Header: ASExtraProcs.h:1927

Description

Creates a time record that represents the UTC time represented by the date object. It raises an exception if there is not enough memory.

Syntax

ASTimeRec ASDateGetUTCTime(const ASDate date);

Parameters

date
The date object.

Returns

The newly created time record.

ASDateNew

Header: ASExtraProcs.h:1646

Description

Creates a date object. The newly allocated object reflects the epoch time: Jan 1 1970 00:00:00 UTC.

Raises an exception if there is not enough memory for the operation.

Syntax

ASDate ASDateNew(void);

Returns

The newly created date object.

ASDateSetLocalTimeOffset

Header: ASExtraProcs.h:1768

Description

Sets a date object's local time offset according to the operating system's current time zone information. Different operating systems handle daylight savings differently. This method causes the date object to always use the same daylight savings time offset that the operating system is currently using, even if the date object is modified.

Syntax

void ASDateSetLocalTimeOffset(ASDate date);

Parameters

date
The date.

ASDateSetTimeFromRec

Header: ASExtraProcs.h:1801

Description

Initializes a date object from a time record. It raises an exception if the time structure represents an invalid time, such as January 32nd 1999 or Feb 29th 2001. It assumes that the parameters for the day and month in the time record are 1-based.

Syntax

void ASDateSetTimeFromRec(ASDate date, const ASTimeRec *timeRec);

Parameters

date
The date object.
timeRec
The time record.

ASDateSetTimeFromString

Header: ASExtraProcs.h:1785

Description

Initializes a date object from a time string. It raises an exception if there is not enough memory, if the format is unrecognized, or if the time string is not formatted according to the supplied format.

Syntax

void ASDateSetTimeFromString(ASDate date, const char *timeString, ASDateTimeFormat format);

Parameters

date
The date object.
timeString
The time string, in the specified format.
format
The format of the time string. kASTimeNone and kASTimeUniversalH are not supported.

ASDateSetToCurrentLocalTime

Header: ASExtraProcs.h:1754

Description

Sets a date object to the current local time, using the time zone information from the operating system.

Syntax

void ASDateSetToCurrentLocalTime(ASDate date);

Parameters

date
The date.

ASDateSetToCurrentUTCTime

Header: ASExtraProcs.h:1742

Description

Sets a date object to the current UTC time with no time zone information.

Syntax

void ASDateSetToCurrentUTCTime(ASDate retVal);

Parameters

retVal
The date.

ASDateSubtractCalendarTimeSpan

Header: ASExtraProcs.h:1822

Description

Subtracts a calendar time span from a date. It modifies the date by the length of time provided in the ASCalendarTimeSpan object.

Note: There is some ambiguity in a calendar time span; to subtract an exact time span (for example, 2592000 seconds rather than one month), use ASDateSubtractTimeSpan().

Syntax

void ASDateSubtractCalendarTimeSpan(ASDate date, const ASCalendarTimeSpan timeSpan);

Parameters

date
The date.
timeSpan
The calendar time span to subtract.

ASDateSubtractTimeSpan

Header: ASExtraProcs.h:1849

Description

Subtracts a time span (an exact number of seconds) from a date. It modifies the date by the length of time provided in the ASTimeSpan object.

Syntax

void ASDateSubtractTimeSpan(ASDate date, const ASTimeSpan timeSpan);

Parameters

date
The date.
timeSpan
The time span to subtract.