Leaked source code of windows server 2003
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.7 KiB

  1. /***
  2. *strtime.c - contains the function "_strtime()"
  3. *
  4. * Copyright (c) 1989-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * contains the function _strtime()
  8. *
  9. *Revision History:
  10. * 06-07-89 PHG Module created, based on asm version
  11. * 03-20-90 GJF Made calling type _CALLTYPE1, added #include
  12. * <cruntime.h> and fixed the copyright. Also, cleaned
  13. * up the formatting a bit.
  14. * 07-25-90 SBM Removed '32' from API names
  15. * 10-04-90 GJF New-style function declarator.
  16. * 12-04-90 SRW Changed to include <oscalls.h> instead of <doscalls.h>
  17. * 12-06-90 SRW Added _CRUISER_ and _WIN32 conditionals.
  18. * 05-19-92 DJM ifndef for POSIX build.
  19. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  20. * 11-01-93 CFW Enable Unicode variant, rip out Cruiser.
  21. * 02-10-95 GJF Merged in Mac version.
  22. * 05-17-99 PML Remove all Macintosh support.
  23. *
  24. *******************************************************************************/
  25. #ifndef _POSIX_
  26. #include <cruntime.h>
  27. #include <time.h>
  28. #include <tchar.h>
  29. #include <oscalls.h>
  30. /***
  31. *_TSCHAR *_strtime(buffer) - return time in string form
  32. *
  33. *Purpose:
  34. * _strtime() returns a string containing the time in "HH:MM:SS" form
  35. *
  36. *Entry:
  37. * _TSCHAR *buffer = the address of a 9-byte user buffer
  38. *
  39. *Exit:
  40. * returns buffer, which contains the time in "HH:MM:SS" form
  41. *
  42. *Exceptions:
  43. *
  44. *******************************************************************************/
  45. _TSCHAR * __cdecl _tstrtime (
  46. _TSCHAR *buffer
  47. )
  48. {
  49. int hours, minutes, seconds;
  50. SYSTEMTIME dt; /* Win32 time structure */
  51. GetLocalTime(&dt);
  52. hours = dt.wHour;
  53. minutes = dt.wMinute;
  54. seconds = dt.wSecond;
  55. /* store the components of the time into the string */
  56. /* store separators */
  57. buffer[2] = buffer[5] = _T(':');
  58. /* store end of string */
  59. buffer[8] = _T('\0');
  60. /* store tens of hour */
  61. buffer[0] = (_TSCHAR) (hours / 10 + _T('0'));
  62. /* store units of hour */
  63. buffer[1] = (_TSCHAR) (hours % 10 + _T('0'));
  64. /* store tens of minute */
  65. buffer[3] = (_TSCHAR) (minutes / 10 + _T('0'));
  66. /* store units of minute */
  67. buffer[4] = (_TSCHAR) (minutes % 10 + _T('0'));
  68. /* store tens of second */
  69. buffer[6] = (_TSCHAR) (seconds / 10 + _T('0'));
  70. /* store units of second */
  71. buffer[7] = (_TSCHAR) (seconds % 10 + _T('0'));
  72. return buffer;
  73. }
  74. #endif /* _POSIX_ */