Converting Long Date and Time Values Into Strings


Mac OS X header: CoreServices/CoreServices.h
Mac OS 9 header: DateTimeUtils.h


Converting Long Date and Time Values Into Strings Functions
LongDateString Converts a date that is specified as a LongDateTime value into a Pascal string, making use of the date formatting information in the specified resource.
LongTimeString Converts a time that is specified as a LongDateTime value into a Pascal string, making use of the time formatting information in the specified resource.


LongDateString

Carbon status: Supported

Converts a date that is specified as a LongDateTime value into a Pascal string, making use of the date formatting information in the specified resource.

void LongDateString (
    const LongDateTime *dateTime, 
    DateForm longFlag, 
    Str255 result, 
    Handle intlHandle
);
Parameter descriptions
dateTime

A pointer to a 64-bit, signed representation of the number of seconds since Jan. 1, 1904. This allows coverage of a much longer span of time (plus or minus approximately 30,000 years) than the standard, 32-bit representation.

longFlag

A flag that indicates the desired format for the date string. This is one of the three values defined as the DateForm type.

The string produced by LongDateString is in one of three standard date formats used on the Macintosh, depending on which of the three DateForm values that you specify for the longFlag parameter: shortDate, abbrevDate, or longDate. The information in the supplied resource defines how month and day names are written and provides for calendars with more than 7 days and more than 12 months.

For the U.S. resource, the date January 31, 1991, produces the following three strings: “1/31/92“, “Fri, Jan 31, 1992“, and “Fri, January 31, 1992“ (for DateForm values shortDate, abbrevDate, and longDate, respectively).

result

On output, contains the string representation of the date in the format indicated by the longFlag parameter.

intlHandle

A handle to a numeric-format or long-date-format resource that specifies date formatting information for use in the conversion. If you specify NULL as the value of the resource handle parameter, LongDateString uses information from the current script.The numeric-format ('itl0') resource specifies the short date formats and the long-date-format ('itl1') resource specifies the long date formats.

If you specify shortDate in the longFlag parameter, the intlHandle value should be the handle to a numeric-format resource; if you specify abbrevDate or longDate, it should be the handle to a long-date-format resource.

Discussion

You can use the LongSecondsToDate and LongDateToSeconds functions to convert between the LongDateRec (as produced by the StringToDate function) and LongDateTime data types.

Availability

Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.

Special Considerations

LongDateString may move memory; your application should not call this function at interrupt time.


LongTimeString

Carbon status: Supported

Converts a time that is specified as a LongDateTime value into a Pascal string, making use of the time formatting information in the specified resource.

void LongTimeString (
    const LongDateTime *dateTime, 
    Boolean wantSeconds, 
    Str255 result, 
    Handle intlHandle
);
Parameter descriptions
dateTime

A pointer to a 64-bit, signed representation of the number of seconds since Jan. 1, 1904. This allows coverage of a much longer span of time (plus or minus approximately 30,000 years) than the standard, 32-bit representation.

wantSeconds

A flag that indicates whether the seconds are to be included in the resulting string. LongTimeString produces a string that includes the seconds if you set this parameter to TRUE.

result

On output, contains the string representation of the time.

intlHandle

A handle to a numeric-format ('itl0') resource that specifies time formatting information for use in the conversion. If you specify NULL as the value of the resource handle parameter, LongTimeString uses information from the current script.

The numeric-format resource specifies whether or not to use leading zeros for the time values, whether to use a 12- or 24-hour time cycle, and how to specify morning or evening if a 12-hour time cycle is used.

Discussion

You can use the LongSecondsToDate and LongDateToSeconds functions to convert between the LongDateRec (as produced by the StringToTime function) and LongDateTime data types.

Availability

Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.

Special Considerations

LongTimeString may move memory; your application should not call this function at interrupt time.


© 2001 Apple Computer, Inc. (Last Updated July 17, 2001)