Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1991-1993 Microsoft Corporation
  3. Module Name:
  4. TimeZone.c
  5. Abstract:
  6. This file just contains NetpLocalTimeZoneOffset(). (It is the only
  7. NetLib time function used by SRVSVC.DLL at this time, and ChuckL wants
  8. to keep that DLL as small as possible.)
  9. Author:
  10. JR (John Rogers, JohnRo@Microsoft) 20-Aug-1992
  11. Environment:
  12. Interface is portable to any flat, 32-bit environment.
  13. Uses Win32 typedefs.
  14. Requires ANSI C extensions: slash-slash comments, long external names.
  15. Revision History:
  16. 20-Aug-1992 JohnRo
  17. RAID 2920: Support UTC timezone in net code.
  18. 01-Oct-1992 JohnRo
  19. RAID 3556: Added NetpSystemTimeToGmtTime() for DosPrint APIs.
  20. 15-Apr-1993 Danl
  21. Fixed NetpLocalTimeZoneOffset so that it uses the windows calls and
  22. obtains the correct bias.
  23. 14-Jun-1993 JohnRo
  24. RAID 13080: Allow repl between different timezones.
  25. Also, DanL asked me to remove printf() call.
  26. 18-Jun-1993 JohnRo
  27. RAID 13594: Extracted NetpLocalTimeZoneOffset() so srvsvc.dll doesn't
  28. get too big.
  29. Use NetpKdPrint() where possible.
  30. --*/
  31. // These must be included first:
  32. #include <windows.h>
  33. // These may be included in any order:
  34. #include <netdebug.h> // NetpAssert(), NetpKdPrint(), FORMAT_ equates.
  35. #include <prefix.h> // PREFIX_ equates.
  36. #include <timelib.h> // My prototypes.
  37. LONG // Number of seconds from UTC. Positive values for west of Greenwich,
  38. // negative values for east of Greenwich.
  39. NetpLocalTimeZoneOffset(
  40. VOID
  41. )
  42. {
  43. TIME_ZONE_INFORMATION tzInfo;
  44. LONG bias;
  45. switch (GetTimeZoneInformation(&tzInfo)) {
  46. case TIME_ZONE_ID_DAYLIGHT:
  47. bias = tzInfo.Bias + tzInfo.DaylightBias;
  48. break;
  49. case TIME_ZONE_ID_STANDARD:
  50. bias = tzInfo.Bias + tzInfo.StandardBias;
  51. break;
  52. case TIME_ZONE_ID_UNKNOWN:
  53. bias = tzInfo.Bias;
  54. break;
  55. default:
  56. NetpKdPrint(( PREFIX_NETLIB
  57. "NetpLocalTimeZoneOffset: GetTimeZoneInformation failed.\n" ));
  58. return(0);
  59. }
  60. bias *= 60;
  61. return(bias);
  62. } // NetpLocalTimeZoneOffset