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.

91 lines
2.3 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. extern INT cchTimeMax;
  14. extern INT cchLongDateMax;
  15. extern CHAR *rgszDayAbbrevs[];
  16. void
  17. LockStrings(id)
  18. WORD id;
  19. {
  20. HANDLE h;
  21. if ((h = FindResource(hinstTimeDate, MAKEINTRESOURCE(IDS_DATESTRINGS >> 4), RT_STRING))
  22. && (h = LoadResource(hinstTimeDate, h))) {
  23. GlobalLock(h);
  24. }
  25. }
  26. void
  27. CalcCchDateMax(idFirst, idLast)
  28. WORD idFirst;
  29. WORD idLast;
  30. {
  31. CHAR rgch[30];
  32. register INT cch, cchT;
  33. cch = 0;
  34. while (idFirst <= idLast) {
  35. cchT = LoadString(hinstTimeDate, idFirst++, rgch, 30);
  36. if (cchT > cch)
  37. cch = cchT;
  38. }
  39. cchLongDateMax += cch;
  40. }
  41. BOOL FAR APIENTRY InitLongTimeDate(UINT format)
  42. {
  43. INT cchT;
  44. INT i;
  45. CHAR rgch[30];
  46. LANGID PrimaryLangID = PRIMARYLANGID(GetSystemDefaultLangID());
  47. /* Get date/time strings into memory & lock down for all time */
  48. LockStrings(((WORD)IDS_DATESTRINGS >> 4) + 0);
  49. LockStrings(((WORD)IDS_DATESTRINGS >> 4) + 1);
  50. /* Now calculate worst case size of long date string */
  51. /* this is sum of separator strings, plus max of months, plus max of
  52. weekdays, plus 2 digits, plus 4 digits, plus zero terminator */
  53. cchLongDateMax = 2 + 4;
  54. CalcCchDateMax(IDS_MONTHS, IDS_MONTHS+11);
  55. #ifdef LEPPARD
  56. for (i = IDS_SEPSTRINGS; i <= IDS_SEPSTRINGS+4; i++) {
  57. cchLongDateMax += LoadString(hinstTimeDate, i, rgch, 30);
  58. }
  59. #else
  60. cchLongDateMax += 5; /* room for spaces and commas */
  61. #endif
  62. CalcCchDateMax(IDS_DAYSOFWEEK, IDS_DAYSOFWEEK+6);
  63. //
  64. // See if it's Japanese or Korean.
  65. //
  66. if ((PrimaryLangID == LANG_JAPANESE) || (PrimaryLangID == LANG_KOREAN))
  67. {
  68. cchLongDateMax += LoadString(hinstTimeDate, IDS_SEPSTRINGS+5, rgch, 30);
  69. cchLongDateMax += LoadString(hinstTimeDate, IDS_SEPSTRINGS+6, rgch, 30);
  70. }
  71. /* Calc max size of time string */
  72. cchT = 0;
  73. if (!f24Time) {
  74. cchT = lstrlen(sz2359);
  75. cchTimeMax = lstrlen(sz1159);
  76. if (cchT > cchTimeMax)
  77. cchTimeMax = cchT;
  78. }
  79. cchTimeMax += 6;
  80. return TRUE;
  81. }