| Mac OS X header: | CoreServices/CoreServices.h |
| Mac OS 9 header: | DateTimeUtils.h |
| Setting the Current Date and Time Functions | |
| SetDateTime | Changes the date-time information stored in the clock chip to the specified value, expressed as the number of seconds elapsed since midnight, January 1, 1904. |
| SetTime | Changes the date-time information in the clock chip to the specified value, expressed as a date and time. |
SetDateTime |
| Carbon status: | Supported |
Changes the date-time information stored in the clock chip to the specified value, expressed as the number of seconds elapsed since midnight, January 1, 1904.
OSErr SetDateTime (
UInt32 time
);
The number of seconds elapsed since midnight, January 1, 1904; this value is written to the clock chip.
A result code. The SetDateTime function attempts to verify the value written by reading it back in and comparing it to the value in the low-memory copy. If a problem occurs, the SetDateTime function returns either the clkRdErr result code, because the clock chip could not be read, or the clkWrErr result code, because the time written to the clock chip could not be verified. Otherwise, the function returns the noErr result code.
The SetDateTime function also updates the low-memory copy of the date-time information.
Users can change the current date and time stored in both the system global variable Time and in the clock chip by using the General Controls control panel, Date & Time control panel, or the Alarm Clock desk accessory. In general, your application should not directly change the current date-time information. If your application does need to modify the current date-time information, it should instruct the user how to change the date and time.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
SetTime |
| Carbon status: | Supported |
Changes the date-time information in the clock chip to the specified value, expressed as a date and time.
void SetTime (
const DateTimeRec *d
);
The date and time to which to set the clock chip.
The SetTime function first converts the date and time to the number of seconds elapsed since midnight, January 1, 1904 by calling the DateToSeconds function. It then writes these seconds to the clock chip and to the system global variable Time by calling the SetDateTime function.
The SetTime function does not return a result code. If you need to know whether an attempt to change the date and time information in the clock chip is successful, you must use the SetDateTime function.
As an alternative to using the SetTime procedure, you can use the
Users can change the current date and time stored in both the system global variable Time and in the clock chip by using the General Controls control panel, Date & Time control panel, or the Alarm Clock desk accessory. In general, your application should not directly change the current date-time information. If your application does need to modify the current date-time information, it should instruct the user how to change the date and time.
See
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
© 2001 Apple Computer, Inc. (Last Updated July 17, 2001)