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.

107 lines
3.0 KiB

4 years ago
  1. /***
  2. *ftime.c - OS/2 return system time
  3. *
  4. * Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Returns the system date/time in a structure form.
  8. *
  9. *Revision History:
  10. * 03-??-84 RLB initial version
  11. * 05-17-86 SKS ported to OS/2
  12. * 03-09-87 SKS correct Daylight Savings Time flag
  13. * 11-18-87 SKS Change tzset() to __tzset()
  14. * 12-11-87 JCR Added "_LOAD_DS" to declaration
  15. * 10-03-88 JCR 386: Change DOS calls to SYS calls
  16. * 10-04-88 JCR 386: Removed 'far' keyword
  17. * 10-10-88 GJF Made API names match DOSCALLS.H
  18. * 04-12-89 JCR New syscall interface
  19. * 05-25-89 JCR 386 OS/2 calls use '_syscall' calling convention
  20. * 03-20-90 GJF Replaced _LOAD_DS with _CALLTYPE1, added #include
  21. * <cruntime.h>, removed some leftover 16-bit support
  22. * and fixed the copyright. Also, cleaned up the
  23. * formatting a bit.
  24. * 07-25-90 SBM Removed '32' from API names
  25. * 08-13-90 SBM Compiles cleanly with -W3
  26. * 08-20-90 SBM Removed old incorrect, redundant tp->dstflag assignment
  27. * 10-04-90 GJF New-style function declarator.
  28. * 12-04-90 SRW Changed to include <oscalls.h> instead of <doscalls.h>
  29. * 12-06-90 SRW Added _CRUISER_ and _WIN32 conditionals.
  30. * 01-21-91 GJF ANSI naming.
  31. * 01-23-92 GJF Change in time zone field name for Win32, to support
  32. * crtdll.dll [_WIN32_].
  33. * 03-30-93 GJF Revised to use mktime(). Also purged Cruiser support.
  34. * 06-08-93 SKS Change "tmzone" back to "timezone". See h/sys/timeb.h.
  35. * 07-15-93 GJF Call __tzset() instead of _tzset().
  36. *
  37. *******************************************************************************/
  38. #ifndef _POSIX_
  39. #include <cruntime.h>
  40. #include <sys/types.h>
  41. #include <sys/timeb.h>
  42. #include <time.h>
  43. #include <dostypes.h>
  44. #include <msdos.h>
  45. #include <dos.h>
  46. #include <stdlib.h>
  47. #include <oscalls.h>
  48. #include <internal.h>
  49. /***
  50. *void _ftime(timeptr) - return DOS time in a structure
  51. *
  52. *Purpose:
  53. * returns the current DOS time in a struct timeb structure
  54. *
  55. *Entry:
  56. * struct timeb *timeptr - structure to fill in with time
  57. *
  58. *Exit:
  59. * no return value -- fills in structure
  60. *
  61. *Exceptions:
  62. *
  63. *******************************************************************************/
  64. void _CRTAPI1 _ftime (
  65. struct _timeb *tp
  66. )
  67. {
  68. struct tm tb;
  69. SYSTEMTIME dt;
  70. __tzset();
  71. /*
  72. * NOTE: The "timezone" field was renamed "tmzone" for a while because
  73. * of the conflict with the global variable "_timezone". Since we use
  74. * #define to alias the old name "timezone" to "_timezone" and to
  75. * alias _timezone to (*_timezone_dll) in the CRTDLL model, we cannot
  76. * compatibility in both areas. See sys/timeb.h for more information.
  77. */
  78. tp->timezone = (short)(_timezone / 60);
  79. GetLocalTime(&dt);
  80. tp->millitm = (unsigned short)(dt.wMilliseconds);
  81. tb.tm_year = dt.wYear - 1900;
  82. tb.tm_mday = dt.wDay;
  83. tb.tm_mon = dt.wMonth - 1;
  84. tb.tm_hour = dt.wHour;
  85. tb.tm_min = dt.wMinute;
  86. tb.tm_sec = dt.wSecond;
  87. tb.tm_isdst = -1;
  88. /*
  89. * Call mktime() to compute time_t value and Daylight Savings Time
  90. * flag.
  91. */
  92. tp->time = mktime(&tb);
  93. tp->dstflag = (short)(tb.tm_isdst);
  94. }
  95. #endif /* _POSIX_ */