![]() |
ToggleDate |
||||
Header: | DateTimeUtils.h | Carbon status: | Supported | |
Modifies a date and time, by modifying one specific component of a date and time (day, hour, minute, seconds, day of week, and so on).
ToggleResults ToggleDate ( LongDateTime *lSecs, LongDateField field, DateDelta delta, SInt16 ch, const TogglePB *params );
The date-time information to modify, expressed as the number of seconds elapsed since midnight, January 1, 1904.
The name of the field in the date-time structure you want modify. Use one of the
A signed byte specifying the action you want to perform on the value specified in the field parameter. Set delta to 1, to increase the value in the field by 1. Set delta to -1, to decrease the value of the field by 1. Set delta to 0. If you want to set the value of the field explicitly; pass the new value through the ch field.
If the value in the delta field is 0, the value of the field in the date-time structure (specified by the field parameter) is set to the value in the ch parameter. If the value in the delta field is not equal to 0, the value in the ch parameter is ignored.
The user-defined settings of the toggle parameter block settings.
The relevant fields of the toggle parameter block are:
A value of type SInt32. On input, the fields to be checked by the ValidDate function.
A value of type ResType. On input, A.M. characters from 'itl0' resource.
A value of type ResType. On input, P.M. characters from 'itl0' resource.
An array of SInt32 values. Reserved; on input, set each element to 0.
You must supply values for all input parameters.
The ToggleDate function first converts the number of seconds and makes each component of the date and time available through a long date-time structure. The ToggleDate function then modifies the value of the field, specified by the field parameter. If the value in the delta field is greater than 0, the value of the field increases by 1; if the value in the delta field is less than 0, the value of the field decreases by 1; and if the value of delta is 0, the value of the field is explicitly set to the value specified in the ch field. After the ToggleDate function modifies the field, it calls the ValidDate function. The ValidDate function checks the long date-time structure for correctness. If any of the structure fields are invalid, the ValidDate function returns a LongDateField value corresponding to the field in error. Otherwise, it returns the result code for validDateFields. Note that ValidDate reports only the least significant erroneous field.
After the ToggleDate function checks the validity of the modified field, it converts the modified date and time back into a number of seconds and returns these seconds in the lSecs parameter.
The ToggleDate function was previously available with the Script Manager.
For more information on the LongDateRec structure, see LongDateRec. The toggle parameter block structure is described in TogglePB.
For more information about the GetIntlResource function, see the Script Manager. For details on the UppercaseText function, see Text Utilities.
Although ToggleDate does not move or purge memory; you should not call it at interrupt time.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)