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. *strdate.c - contains the function "_strdate()"
  3. *
  4. * Copyright (c) 1989-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * contains the function _strdate()
  8. *
  9. *Revision History:
  10. * 06-07-89 PHG Module created, base 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 <tchar.h>
  28. #include <time.h>
  29. #include <oscalls.h>
  30. /***
  31. *_TSCHAR *_strdate(buffer) - return date in string form
  32. *
  33. *Purpose:
  34. * _strdate() returns a string containing the date in "MM/DD/YY" form
  35. *
  36. *Entry:
  37. * _TSCHAR *buffer = the address of a 9-byte user buffer
  38. *
  39. *Exit:
  40. * returns buffer, which contains the date in "MM/DD/YY" form
  41. *
  42. *Exceptions:
  43. *
  44. *******************************************************************************/
  45. _TSCHAR * __cdecl _tstrdate (
  46. _TSCHAR *buffer
  47. )
  48. {
  49. int month, day, year;
  50. SYSTEMTIME dt; /* Win32 time structure */
  51. GetLocalTime(&dt);
  52. month = dt.wMonth;
  53. day = dt.wDay;
  54. year = dt.wYear % 100; /* change year into 0-99 value */
  55. /* store the components of the date into the string */
  56. /* store seperators */
  57. buffer[2] = buffer[5] = _T('/');
  58. /* store end of string */
  59. buffer[8] = _T('\0');
  60. /* store tens of month */
  61. buffer[0] = (_TSCHAR) (month / 10 + _T('0'));
  62. /* store units of month */
  63. buffer[1] = (_TSCHAR) (month % 10 + _T('0'));
  64. /* store tens of day */
  65. buffer[3] = (_TSCHAR) (day / 10 + _T('0'));
  66. /* store units of day */
  67. buffer[4] = (_TSCHAR) (day % 10 + _T('0'));
  68. /* store tens of year */
  69. buffer[6] = (_TSCHAR) (year / 10 + _T('0'));
  70. /* store units of year */
  71. buffer[7] = (_TSCHAR) (year % 10 + _T('0'));
  72. return buffer;
  73. }
  74. #endif /* _POSIX_ */