Important: The information in this document is obsolete and should not be used for new development.
SetDateTime
You can use theSetDateTimefunction to modify the date-time information stored in the clock chip. TheSetDateTimefunction requires that the new date-time information be passed to the function as the number of seconds elapsed since midnight, January 1, 1904.
FUNCTION SetDateTime (time: LongInt): OSErr;
time- The number of seconds elapsed since midnight, January 1, 1904; this value is written to the clock chip.
DESCRIPTION
TheSetDateTimefunction writes the number of seconds, specified by thetimeparameter, to the clock chip. TheSetDateTimefunction also updates the low-memory copy of the date-time information.The
SetDateTimefunction 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, theSetDateTimefunction returns either theclkRdErrresult code, because the clock chip could not be read, or theclkWrErrresult code, because the time written to the clock chip could not be verified. Otherwise, the function returns thenoErrresult code.ASSEMBLY-LANGUAGE INFORMATION
You must set up register D0 with the number of seconds to which you wish to change the clock chip. When theSetDateTimefunction returns, register D0 contains the result code.The registers on entry and exit for this routine are
Registers on entry D0 Seconds elapsed since midnight, January 1, 1904
Registers on exit D0 Result code RESULT CODES
noErr 0 No error clkRdErr -85 Unable to read clock clkWrErr -86 Time written did not verify SEE ALSO
For sample code that uses theSetDateTimefunction to write date-time information (represented as a number of seconds) to the clock-chip, see Listing 4-3 on page 4-11.