Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Previous Book Contents Book Index Next

Inside Macintosh: Operating System Utilities /
Chapter 4 - Date, Time, and Measurement Utilities / Date, Time, and Measurement Utilities Reference
Routines / Setting the Current Date and Time


SetDateTime

You can use the SetDateTime function to modify the date-time information stored in the clock chip. The SetDateTime function 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
The SetDateTime function writes the number of seconds, specified by the time parameter, to the clock chip. The SetDateTime function also updates the low-memory copy of the date-time information.

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.

ASSEMBLY-LANGUAGE INFORMATION
You must set up register D0 with the number of seconds to which you wish to change the clock chip. When the SetDateTime function returns, register D0 contains the result code.

The registers on entry and exit for this routine are
Registers on entry
D0Seconds elapsed since midnight, January 1, 1904
Registers on exit
D0Result code

RESULT CODES
noErr0No error
clkRdErr-85Unable to read clock
clkWrErr-86Time written did not verify
SEE ALSO
For sample code that uses the SetDateTime function to write date-time information (represented as a number of seconds) to the clock-chip, see Listing 4-3 on page 4-11.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996

Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2004 Apple Computer, Inc.
All rights reserved. | Terms of use | Privacy Notice