Technotes
While you can set the Daylight Savings Time state from the Date & Time Control Panel and determine what the state is by checking the checkbox in the Control Panel, you can also figure out the state from within your program. This Technote shows you how. Inside Macintosh: Operating System Utilities, Chapter 4, does not directly explain how you can find out if daylight savings time is in effect. With the MachineLocation data structure dlsDelta field, you can find out how the time would have changed, but the field does not tell you whether daylight savings time is in effect. This Technote is aimed at Macintosh developers who must deal with date and time programming issues. Using the dlsDelta fieldThe Daylight Savings Time state is stored in the gmtDelta field of the MachineLocation structure. The API to access this structure is the Script Manager call ReadLocation. Unfortunately, there is not enough documentation on the MachineLocation structure in general and no official standards on the use of the gmtDelta field.Preserving the 3-Byte ValueCurrently, the dlsDelta field is not being used by Macintosh system software, nor is its meaning defined. It may be used in the future, so it's important that you preserve its current value if you ever use WriteLocation to set the value of gmtDelta.The top byte of the gmtDelta should be masked off and preserved when writing: it's reserved for future extension. The gmtDelta is really a 3-byte value, so you must take care to get and set it properly, as in the following C code examples: #include A Routine That Checks the StateThe following routine shows exactly what you need to do in order to determine if the daylight savings time is on. It is important to note that the dlsDelta field is declared to be signed char. If this is not declared, the if condition will always return false, even if the daylight savings time is set to true.#includeVersions of the Date & Time Control Panel greater than 7.1 set the high bit of the high byte if Daylight Savings is checked "on" in the CDEV. The Map CDEF has not yet been revised to use this field. Future versions of Map or Date & Time may use the byte differently, so be sure to use it with caution.
Further Reference
Technotes Previous Technote | Contents | Next Technote |