mactime.h 2.2 KB

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