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.

101 lines
2.9 KiB

  1. #include "windows.h"
  2. #include <port1632.h>
  3. #include "date.h"
  4. extern CHAR chSepDate;
  5. extern CHAR chSepTime;
  6. extern CHAR sz1159[];
  7. extern CHAR sz2359[];
  8. extern INT iDate;
  9. extern INT iYearOffset;
  10. extern BOOL f24Time;
  11. extern BOOL fLZero;
  12. extern HANDLE hinstTimeDate;
  13. CHAR * FAR APIENTRY Int2Ascii();
  14. CHAR * APIENTRY LoadDateString();
  15. #define LDS_DAYOFWEEK 0
  16. #define LDS_MONTH 1
  17. #define LDS_DAY 2
  18. #define LDS_YEAR 3
  19. BYTE mpIFmt[3][4] = {
  20. { LDS_DAYOFWEEK, LDS_MONTH, LDS_DAY, LDS_YEAR },
  21. { LDS_DAYOFWEEK, LDS_DAY, LDS_MONTH, LDS_YEAR },
  22. { LDS_YEAR, LDS_MONTH, LDS_DAY, LDS_DAYOFWEEK }
  23. };
  24. INT FAR APIENTRY GetLongDateString(PDOSDATE pdd, CHAR *pch, WORD format)
  25. {
  26. register INT i;
  27. CHAR *pchSave = pch;
  28. CHAR *szMonth;
  29. INT i1, i2, i3;
  30. INT y;
  31. LANGID PrimaryLangID = PRIMARYLANGID(GetSystemDefaultLangID());
  32. for (i = 1; i <= 4; i++) {
  33. switch (mpIFmt[iDate][i - 1]) {
  34. case LDS_DAYOFWEEK:
  35. if ((format & GDS_DAYOFWEEK)) {
  36. if (pdd->dayofweek == 0xff && ValidateDosDate(pdd) < 0)
  37. return(0);
  38. pch = LoadDateString(pch, IDS_DAYSOFWEEK + pdd->dayofweek);
  39. /* If day of week is at start of string, stick in comma */
  40. if (i == 1)
  41. *pch++ = ',';
  42. if (i != 4)
  43. *pch++ = ' ';
  44. }
  45. break;
  46. case LDS_MONTH:
  47. pch = LoadDateString(pch, pdd->month - 1 + IDS_MONTHS);
  48. *pch++ = ' ';
  49. break;
  50. case LDS_DAY:
  51. if (!(format & GDS_NODAY)) {
  52. pch = Int2Ascii(pdd->day, pch, fLZero);
  53. //
  54. // If it's Japanese or Korean, get native name for year
  55. // from resource.
  56. //
  57. if ((PrimaryLangID == LANG_JAPANESE) ||
  58. (PrimaryLangID == LANG_KOREAN))
  59. {
  60. pch = LoadDateString(pch, IDS_SEPSTRINGS + 6);
  61. }
  62. if (iDate == 0) {
  63. *pch++ = ',';
  64. }
  65. *pch++ = ' ';
  66. }
  67. break;
  68. case LDS_YEAR:
  69. y = pdd->year - iYearOffset;
  70. pch = Int2Ascii(y / 100, pch, TRUE);
  71. pch = Int2Ascii(y % 100, pch, TRUE);
  72. //
  73. // If it's Japanese or Korean, get native name for month
  74. // from resource.
  75. //
  76. if ((PrimaryLangID == LANG_JAPANESE) ||
  77. (PrimaryLangID == LANG_KOREAN))
  78. {
  79. pch = LoadDateString(pch, IDS_SEPSTRINGS + 5);
  80. }
  81. if (i != 4)
  82. *pch++ = ' ';
  83. break;
  84. }
  85. }
  86. *pch = 0;
  87. return(int)(pch - pchSave);
  88. }
  89. CHAR * APIENTRY LoadDateString(pch, id)
  90. register CHAR *pch;
  91. INT id;
  92. {
  93. return(pch + LoadString(hinstTimeDate, id, (LPSTR)pch, 30));
  94. }