| 1 |
/* |
| 2 |
Copyright (c) 1990-2000 Info-ZIP. All rights reserved. |
| 3 |
|
| 4 |
See the accompanying file LICENSE, version 2000-Apr-09 or later |
| 5 |
(the contents of which are also included in zip.h) for terms of use. |
| 6 |
If, for some reason, all these files are missing, the Info-ZIP license |
| 7 |
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html |
| 8 |
*/ |
| 9 |
#ifndef _MACTIME_H_ |
| 10 |
#define _MACTIME_H_ |
| 11 |
/* ----------------------------------------------------------------------------- |
| 12 |
|
| 13 |
The original functions (Metrowerks Codewarrior pro 3.0) gmtime, localtime, |
| 14 |
mktime and time do not work correctly. The supplied link library mactime.c |
| 15 |
contains replacement functions for them. |
| 16 |
|
| 17 |
* Caveat: On a Mac, we only know the GMT and DST offsets for |
| 18 |
* the current time, not for the time in question. |
| 19 |
* Mac has no support for DST handling. |
| 20 |
* DST changeover is all manually set by the user. |
| 21 |
|
| 22 |
|
| 23 |
------------------------------------------------------------------------------*/ |
| 24 |
|
| 25 |
#include <time.h> |
| 26 |
#include <mactypes.h> |
| 27 |
|
| 28 |
/*****************************************************************************/ |
| 29 |
/* Macros, typedefs */ |
| 30 |
/*****************************************************************************/ |
| 31 |
|
| 32 |
|
| 33 |
/* |
| 34 |
* ARGH. Mac times are based on 1904 Jan 1 00:00, not 1970 Jan 1 00:00. |
| 35 |
* So we have to diddle time_t's appropriately: add or subtract 66 years' |
| 36 |
* worth of seconds == number of days times 86400 == (66*365 regular days + |
| 37 |
* 17 leap days ) * 86400 == (24090 + 17) * 86400 == 2082844800L seconds. |
| 38 |
* We hope time_t is an unsigned long (ulg) on the Macintosh... |
| 39 |
*/ |
| 40 |
/* |
| 41 |
This Offset is only used by MacFileDate_to_UTime() |
| 42 |
*/ |
| 43 |
|
| 44 |
#define MACOS_TO_UNIX(x) (x) -= (unsigned long)MacOS_2_Unix |
| 45 |
#define UNIX_TO_MACOS(x) (x) += (unsigned long)MacOS_2_Unix |
| 46 |
|
| 47 |
/* |
| 48 |
The MacOS function GetDateTime returns the |
| 49 |
number of seconds elapsed since midnight, January 1, 1904. |
| 50 |
*/ |
| 51 |
extern const unsigned long MacOS_2_Unix; |
| 52 |
|
| 53 |
|
| 54 |
/* prototypes for public utility functions */ |
| 55 |
time_t MacFtime2UnixFtime(unsigned long macftime); |
| 56 |
unsigned long UnixFtime2MacFtime(time_t unxftime); |
| 57 |
time_t AdjustForTZmoveMac(unsigned long macloctim, long s_gmtoffs); |
| 58 |
Boolean GetGMToffsetMac(unsigned long macftime, long *UTCoffset); |
| 59 |
|
| 60 |
|
| 61 |
#endif |