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.

90 lines
1.6 KiB

  1. /*
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. volume.c
  5. Abstract:
  6. This module contains the routines which manipulates time values and
  7. conversions.
  8. Author:
  9. Jameel Hyder (microsoft!jameelh)
  10. Revision History:
  11. 25 Apr 1992 Initial Version
  12. Notes: Tab stop: 4
  13. --*/
  14. #define FILENUM FILE_TIME
  15. #include <afp.h>
  16. /*** AfpGetCurrentTimeInMacFormat
  17. *
  18. * This gets the current system time in macintosh format which is number of
  19. * seconds since ZERO hours on Jan 1, 2000. Time before this date is
  20. * negative time. (the time returned is the system local time)
  21. */
  22. VOID
  23. AfpGetCurrentTimeInMacFormat(
  24. OUT AFPTIME * pMacTime
  25. )
  26. {
  27. TIME SystemTime;
  28. KeQuerySystemTime(&SystemTime);
  29. *pMacTime = AfpConvertTimeToMacFormat(&SystemTime);
  30. }
  31. /*** AfpConvertTimeToMacFormat
  32. *
  33. * Convert time in the host format i.e. # of 100ns since 1601 A.D. to
  34. * the macintosh time i.e. # of seconds since 2000 A.D. The system time
  35. * is in UTC. We need to first convert it to local time.
  36. */
  37. AFPTIME
  38. AfpConvertTimeToMacFormat(
  39. IN PTIME pSystemTime
  40. )
  41. {
  42. AFPTIME MacTime;
  43. TIME LocalTime;
  44. // Convert this to number of seconds since 1980
  45. RtlTimeToSecondsSince1980(pSystemTime, (PULONG)&MacTime);
  46. MacTime -= SECONDS_FROM_1980_2000;
  47. return MacTime;
  48. }
  49. /*** AfpConvertTimeFromMacFormat
  50. *
  51. * Convert time in the macintosh time i.e. # of seconds since 2000 A.D. to
  52. * the host format i.e. # of 100ns since 1601 A.D. Convert from local time
  53. * to system time i.e UTC.
  54. */
  55. VOID
  56. AfpConvertTimeFromMacFormat(
  57. IN AFPTIME MacTime,
  58. OUT PTIME pSystemTime
  59. )
  60. {
  61. TIME LocalTime;
  62. MacTime += SECONDS_FROM_1980_2000;
  63. RtlSecondsSince1980ToTime(MacTime, pSystemTime);
  64. }
  65.