Windows NT 4.0 source code leak
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.

78 lines
2.0 KiB

4 years ago
  1. /***
  2. *time.c - get current system time
  3. *
  4. * Copyright (c) 1989-1993, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines time() - gets the current system time and converts it to
  8. * internal (time_t) format time.
  9. *
  10. *Revision History:
  11. * 06-07-89 PHG Module created, based on asm version
  12. * 03-20-90 GJF Made calling type _CALLTYPE1, added #include
  13. * <cruntime.h> and fixed the copyright. Also, cleaned
  14. * up the formatting a bit.
  15. * 07-25-90 SBM Removed '32' from API names
  16. * 10-04-90 GJF New-style function declarator.
  17. * 12-04-90 SRW Changed to include <oscalls.h> instead of <doscalls.h>
  18. * 12-06-90 SRW Added _CRUISER_ and _WIN32 conditionals.
  19. * 05-19-92 DJM ifndef for POSIX build.
  20. * 03-30-93 GJF Replaced dtoxtime() reference by __gmtotime_t. Also
  21. * purged Cruiser support.
  22. *
  23. *******************************************************************************/
  24. #ifndef _POSIX_
  25. #include <cruntime.h>
  26. #include <time.h>
  27. #include <oscalls.h>
  28. #include <internal.h>
  29. /***
  30. *time_t time(timeptr) - Get current system time and convert to time_t value.
  31. *
  32. *Purpose:
  33. * Gets the current date and time and stores it in internal (time_t)
  34. * format. The time is returned and stored via the pointer passed in
  35. * timeptr. If timeptr == NULL, the time is only returned, not stored in
  36. * *timeptr. The internal (time_t) format is the number of seconds since
  37. * 00:00:00, Jan 1 1970 (UTC).
  38. *
  39. *Entry:
  40. * time_t *timeptr - pointer to long to store time in.
  41. *
  42. *Exit:
  43. * returns the current time.
  44. *
  45. *Exceptions:
  46. *
  47. *******************************************************************************/
  48. time_t _CRTAPI1 time (
  49. time_t *timeptr
  50. )
  51. {
  52. time_t tim;
  53. SYSTEMTIME dt;
  54. /* ask Win32 for the time, no error possible */
  55. GetSystemTime(&dt);
  56. /* convert using our private routine */
  57. tim = __gmtotime_t((int)dt.wYear,
  58. (int)dt.wMonth,
  59. (int)dt.wDay,
  60. (int)dt.wHour,
  61. dt.wMinute,
  62. dt.wSecond);
  63. if (timeptr)
  64. *timeptr = tim; /* store time if requested */
  65. return tim;
  66. }
  67. #endif /* _POSIX_ */