ReactOS  0.4.15-dev-1397-g19779b3
date.c File Reference
#include "intl.h"
Include dependency graph for date.c:

Go to the source code of this file.

Macros

#define YEAR_STR_MAX_SIZE   5
 
#define MAX_SHRT_DATE_SEPARATORS   3
 
#define STD_DATE_SEP   L"."
 
#define YEAR_DIFF   (99)
 
#define MAX_YEAR   (9999)
 

Functions

BOOL isDateCompAl (WCHAR alpha)
 
LPTSTR FindDateSep (const WCHAR *szSourceStr)
 
static BOOL SetShortDateSep (HWND hwndDlg, PWSTR pszShortDateSep)
 
static BOOL SetShortDateFormat (HWND hwndDlg, PWSTR pszShortDateFmt)
 
static BOOL SetLongDateFormat (HWND hwndDlg, PWSTR pszLongDateFmt)
 
static VOID InitShortDateSepSamples (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
static BOOL CALLBACK ShortDateFormatEnumProc (PWSTR lpTimeFormatString)
 
VOID InitShortDateCB (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
static VOID InitLongDateCB (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
static VOID SetMaxDate (HWND hwndDlg, LCID lcid)
 
static INT GetMaxDate (LCID lcid)
 
static VOID SetMinDate (HWND hwndDlg)
 
static VOID InitMinMaxDateSpin (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
static VOID UpdateDateLocaleSamples (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
static BOOL GetDateSetting (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
INT_PTR CALLBACK DatePageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static HWND hwndEnum = NULL
 

Macro Definition Documentation

◆ MAX_SHRT_DATE_SEPARATORS

#define MAX_SHRT_DATE_SEPARATORS   3

Definition at line 32 of file date.c.

◆ MAX_YEAR

#define MAX_YEAR   (9999)

Definition at line 35 of file date.c.

◆ STD_DATE_SEP

#define STD_DATE_SEP   L"."

Definition at line 33 of file date.c.

◆ YEAR_DIFF

#define YEAR_DIFF   (99)

Definition at line 34 of file date.c.

◆ YEAR_STR_MAX_SIZE

#define YEAR_STR_MAX_SIZE   5

Definition at line 31 of file date.c.

Function Documentation

◆ DatePageProc()

INT_PTR CALLBACK DatePageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 544 of file date.c.

548 {
549  PGLOBALDATA pGlobalData;
550 
551  pGlobalData = (PGLOBALDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
552 
553  switch (uMsg)
554  {
555  case WM_INITDIALOG:
556  pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam;
557  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
558 
559  InitMinMaxDateSpin(hwndDlg, pGlobalData);
560  UpdateDateLocaleSamples(hwndDlg, pGlobalData);
561  InitShortDateCB(hwndDlg, pGlobalData);
562  InitLongDateCB(hwndDlg, pGlobalData);
563  InitShortDateSepSamples(hwndDlg, pGlobalData);
564  /* TODO: Add other calendar types */
565  pGlobalData->bEnableYearNotification = TRUE;
566  break;
567 
568  case WM_COMMAND:
569  switch (LOWORD(wParam))
570  {
571  case IDC_SECONDYEAR_EDIT:
572  if (HIWORD(wParam) == EN_CHANGE &&
573  pGlobalData != NULL &&
574  pGlobalData->bEnableYearNotification == TRUE)
575  {
576  SetMinDate(hwndDlg);
577 
578  /* Enable the Apply button */
579  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
580  }
581  break;
582 
583  case IDC_CALTYPE_COMBO:
584  case IDC_HIJCHRON_COMBO:
588  if (HIWORD(wParam) == CBN_SELCHANGE ||
590  {
591  /* Enable the Apply button */
592  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
593  }
594  break;
595  }
596  break;
597 
598  case WM_NOTIFY:
599  if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
600  {
601  if (GetDateSetting(hwndDlg, pGlobalData))
602  {
603  pGlobalData->bUserLocaleChanged = TRUE;
604  SetMaxDate(hwndDlg, pGlobalData->UserLCID);
605  UpdateDateLocaleSamples(hwndDlg, pGlobalData);
606  }
607  }
608  break;
609  }
610 
611  return FALSE;
612 }
#define IDC_LONGDATEFMT_COMBO
Definition: resource.h:65
static VOID InitShortDateSepSamples(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: date.c:236
static VOID InitMinMaxDateSpin(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: date.c:449
struct _GLOBALDATA * PGLOBALDATA
BOOL bEnableYearNotification
Definition: intl.h:106
#define TRUE
Definition: types.h:120
static VOID UpdateDateLocaleSamples(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: date.c:496
BOOL bUserLocaleChanged
Definition: intl.h:115
#define PSN_APPLY
Definition: prsht.h:117
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
#define LPPROPSHEETPAGE
Definition: prsht.h:390
static BOOL GetDateSetting(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: date.c:519
static VOID SetMaxDate(HWND hwndDlg, LCID lcid)
Definition: date.c:383
#define CBN_EDITCHANGE
Definition: winuser.h:1957
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1722
Definition: inflate.c:139
VOID InitShortDateCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: date.c:295
HWND WINAPI GetParent(_In_ HWND)
#define IDC_SHRTDATEFMT_COMBO
Definition: resource.h:61
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define CBN_SELCHANGE
Definition: winuser.h:1961
static VOID SetMinDate(HWND hwndDlg)
Definition: date.c:425
static VOID InitLongDateCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: date.c:341
#define IDC_SECONDYEAR_EDIT
Definition: resource.h:55
#define HIWORD(l)
Definition: typedefs.h:247
#define IDC_SHRTDATESEP_COMBO
Definition: resource.h:62
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDC_CALTYPE_COMBO
Definition: resource.h:57
#define IDC_HIJCHRON_COMBO
Definition: resource.h:58
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NOTIFY
Definition: richedit.h:61
LCID UserLCID
Definition: intl.h:113
#define EN_CHANGE
Definition: winuser.h:2004

Referenced by CustomizeLocalePropertySheet().

◆ FindDateSep()

LPTSTR FindDateSep ( const WCHAR szSourceStr)

Definition at line 53 of file date.c.

54 {
55  PWSTR pszFoundSep;
56  UINT nDateCompCount=0;
57  UINT nDateSepCount=0;
58 
59  pszFoundSep = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, MAX_SAMPLES_STR_SIZE * sizeof(WCHAR));
60  if (pszFoundSep == NULL)
61  return NULL;
62 
63  wcscpy(pszFoundSep,STD_DATE_SEP);
64 
65  while (nDateCompCount < wcslen(szSourceStr))
66  {
67  if (!isDateCompAl(szSourceStr[nDateCompCount]) && (szSourceStr[nDateCompCount] != L'\''))
68  {
69  while (!isDateCompAl(szSourceStr[nDateCompCount]) && (szSourceStr[nDateCompCount] != L'\''))
70  {
71  pszFoundSep[nDateSepCount++] = szSourceStr[nDateCompCount];
72  nDateCompCount++;
73  }
74 
75  pszFoundSep[nDateSepCount] = L'\0';
76  return pszFoundSep;
77  }
78 
79  nDateCompCount++;
80  }
81 
82  return pszFoundSep;
83 }
uint16_t * PWSTR
Definition: typedefs.h:56
#define MAX_SAMPLES_STR_SIZE
Definition: intl.h:24
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define STD_DATE_SEP
Definition: date.c:33
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
BOOL isDateCompAl(WCHAR alpha)
Definition: date.c:43
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by SetShortDateFormat().

◆ GetDateSetting()

static BOOL GetDateSetting ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 519 of file date.c.

522 {
523  WCHAR szLongDateFormat[MAX_LONGDATEFORMAT];
524  WCHAR szShortDateFormat[MAX_SHORTDATEFORMAT];
525  WCHAR szDateSeparator[MAX_DATESEPARATOR];
526 
527  if (!SetLongDateFormat(hwndDlg, szLongDateFormat) ||
528  !SetShortDateFormat(hwndDlg, szShortDateFormat) ||
529  !SetShortDateSep(hwndDlg, szDateSeparator))
530  {
531  return FALSE;
532  }
533 
534  /* Store settings in global data */
535  wcscpy(pGlobalData->szLongDateFormat, szLongDateFormat);
536  wcscpy(pGlobalData->szShortDateFormat, szShortDateFormat);
537  wcscpy(pGlobalData->szDateSep, szDateSeparator);
538 
539  return TRUE;
540 }
#define TRUE
Definition: types.h:120
static BOOL SetShortDateSep(HWND hwndDlg, PWSTR pszShortDateSep)
Definition: date.c:90
#define MAX_SHORTDATEFORMAT
Definition: intl.h:43
#define FALSE
Definition: types.h:117
static BOOL SetLongDateFormat(HWND hwndDlg, PWSTR pszLongDateFmt)
Definition: date.c:193
WCHAR szDateSep[MAX_DATESEPARATOR]
Definition: intl.h:101
WCHAR szLongDateFormat[MAX_LONGDATEFORMAT]
Definition: intl.h:99
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_DATESEPARATOR
Definition: intl.h:45
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static BOOL SetShortDateFormat(HWND hwndDlg, PWSTR pszShortDateFmt)
Definition: date.c:125
WCHAR szShortDateFormat[MAX_SHORTDATEFORMAT]
Definition: intl.h:100
#define MAX_LONGDATEFORMAT
Definition: intl.h:44

Referenced by DatePageProc().

◆ GetMaxDate()

static INT GetMaxDate ( LCID  lcid)
static

Definition at line 409 of file date.c.

410 {
411  INT nMaxDateVal = 0;
412 
413  GetCalendarInfoW(lcid,
415  CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
416  NULL,
417  0, /* ret type - number */
418  (LPDWORD)&nMaxDateVal);
419 
420  return nMaxDateVal;
421 }
int32_t INT
Definition: typedefs.h:58
#define CAL_GREGORIAN
Definition: winnls.h:440
#define NULL
Definition: types.h:112
uint32_t * LPDWORD
Definition: typedefs.h:59
int WINAPI GetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType, LPWSTR lpCalData, int cchData, LPDWORD lpValue)
Definition: lcformat.c:2485

Referenced by InitMinMaxDateSpin().

◆ InitLongDateCB()

static VOID InitLongDateCB ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 341 of file date.c.

342 {
343  INT nRetCode;
344 
345  /* Limit text length */
347  CB_LIMITTEXT,
349  0);
350 
351  /* Clear all box content */
354  (WPARAM)0,
355  (LPARAM)0);
356 
357  /* Enumerate short long formats */
360 
361  /* Set current item to value from registry */
362  nRetCode = SendDlgItemMessageW(hwndDlg, IDC_LONGDATEFMT_COMBO,
364  -1,
365  (LPARAM)pGlobalData->szLongDateFormat);
366 
367  /* If it is not successful, add new value to list and select them */
368  if (nRetCode == CB_ERR)
369  {
371  CB_ADDSTRING,
372  0,
373  (LPARAM)pGlobalData->szLongDateFormat);
376  -1,
377  (LPARAM)pGlobalData->szLongDateFormat);
378  }
379 }
#define IDC_LONGDATEFMT_COMBO
Definition: resource.h:65
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT
Definition: typedefs.h:58
static BOOL CALLBACK ShortDateFormatEnumProc(PWSTR lpTimeFormatString)
Definition: date.c:283
#define CB_ADDSTRING
Definition: winuser.h:1918
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_LIMITTEXT
Definition: winuser.h:1940
#define CB_RESETCONTENT
Definition: winuser.h:1941
#define CB_ERR
Definition: winuser.h:2410
WCHAR szLongDateFormat[MAX_LONGDATEFORMAT]
Definition: intl.h:99
BOOL WINAPI EnumDateFormatsW(DATEFMT_ENUMPROCW proc, LCID lcid, DWORD flags)
Definition: lcformat.c:2019
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static HWND hwndEnum
Definition: date.c:37
#define CB_SELECTSTRING
Definition: winuser.h:1942
#define DATE_LONGDATE
Definition: winnls.h:194
#define MAX_LONGDATEFORMAT
Definition: intl.h:44
LCID UserLCID
Definition: intl.h:113

Referenced by DatePageProc().

◆ InitMinMaxDateSpin()

static VOID InitMinMaxDateSpin ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 449 of file date.c.

450 {
452  HWND hWndYearSpin;
453 
454  /* Limit text lengths */
456  EM_LIMITTEXT,
458  0);
460  EM_LIMITTEXT,
462  0);
463 
464  hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
465 
466  /* Init max date value */
467  wsprintf(OutBuffer, L"%04d", (DWORD)GetMaxDate(pGlobalData->UserLCID));
469  WM_SETTEXT,
470  0,
471  (LPARAM)OutBuffer);
472 
473  /* Init min date value */
474  wsprintf(OutBuffer, L"%04d", (DWORD)GetMaxDate(pGlobalData->UserLCID) - YEAR_DIFF);
476  WM_SETTEXT,
477  0,
478  (LPARAM)OutBuffer);
479 
480  /* Init updown control */
481  /* Set bounds */
482  SendMessageW(hWndYearSpin,
483  UDM_SETRANGE,
484  0,
486 
487  /* Set current value */
488  SendMessageW(hWndYearSpin,
489  UDM_SETPOS,
490  0,
491  MAKELONG(GetMaxDate(pGlobalData->UserLCID),0));
492 }
#define EM_LIMITTEXT
Definition: winuser.h:1982
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
#define MAX_YEAR
Definition: date.c:35
#define IDC_SCR_MAX_YEAR
Definition: resource.h:56
#define IDC_FIRSTYEAR_EDIT
Definition: resource.h:54
#define YEAR_DIFF
Definition: date.c:34
#define MAKELONG(a, b)
Definition: typedefs.h:249
LONG_PTR LPARAM
Definition: windef.h:208
#define UDM_SETRANGE
Definition: commctrl.h:2137
#define WM_SETTEXT
Definition: winuser.h:1599
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define YEAR_STR_MAX_SIZE
Definition: date.c:31
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR L[]
Definition: oid.c:1250
#define MAX_YEAR_EDIT
Definition: intl.h:46
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define UDM_SETPOS
Definition: commctrl.h:2139
#define IDC_SECONDYEAR_EDIT
Definition: resource.h:55
#define wsprintf
Definition: winuser.h:5840
static INT GetMaxDate(LCID lcid)
Definition: date.c:409
LCID UserLCID
Definition: intl.h:113

Referenced by DatePageProc().

◆ InitShortDateCB()

VOID InitShortDateCB ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)

Definition at line 295 of file date.c.

296 {
297  INT nRetCode;
298 
299  /* Limit text lengths */
301  CB_LIMITTEXT,
303  0);
305  CB_LIMITTEXT,
307  0);
308 
309  /* Clear all box content */
312  (WPARAM)0,
313  (LPARAM)0);
314 
315  /* Enumerate short date formats */
318 
319  /* Set current item to value from registry */
320  nRetCode = SendDlgItemMessageW(hwndDlg, IDC_SHRTDATEFMT_COMBO,
322  -1,
323  (LPARAM)pGlobalData->szShortDateFormat);
324 
325  /* If it is not successful, add new value to list and select them */
326  if (nRetCode == CB_ERR)
327  {
329  CB_ADDSTRING,
330  0,
331  (LPARAM)pGlobalData->szShortDateFormat);
334  -1,
335  (LPARAM)pGlobalData->szShortDateFormat);
336  }
337 }
#define DATE_SHORTDATE
Definition: winnls.h:193
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT
Definition: typedefs.h:58
#define MAX_SHORTDATEFORMAT
Definition: intl.h:43
static BOOL CALLBACK ShortDateFormatEnumProc(PWSTR lpTimeFormatString)
Definition: date.c:283
#define CB_ADDSTRING
Definition: winuser.h:1918
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_LIMITTEXT
Definition: winuser.h:1940
#define CB_RESETCONTENT
Definition: winuser.h:1941
#define CB_ERR
Definition: winuser.h:2410
BOOL WINAPI EnumDateFormatsW(DATEFMT_ENUMPROCW proc, LCID lcid, DWORD flags)
Definition: lcformat.c:2019
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define MAX_DATESEPARATOR
Definition: intl.h:45
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static HWND hwndEnum
Definition: date.c:37
#define CB_SELECTSTRING
Definition: winuser.h:1942
WCHAR szShortDateFormat[MAX_SHORTDATEFORMAT]
Definition: intl.h:100
#define IDC_SHRTDATEFMT_COMBO
Definition: resource.h:61
#define IDC_SHRTDATESEP_COMBO
Definition: resource.h:62
LCID UserLCID
Definition: intl.h:113

Referenced by DatePageProc().

◆ InitShortDateSepSamples()

static VOID InitShortDateSepSamples ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 236 of file date.c.

237 {
238  PWSTR ShortDateSepSamples[MAX_SHRT_DATE_SEPARATORS] =
239  {
240  L".",
241  L"/",
242  L"-"
243  };
244  INT nCBIndex;
245  INT nRetCode;
246 
247  /* Clear all box content */
250  (WPARAM)0,
251  (LPARAM)0);
252 
253  /* Create standard list of separators */
254  for (nCBIndex = 0; nCBIndex < MAX_SHRT_DATE_SEPARATORS; nCBIndex++)
255  {
257  CB_ADDSTRING,
258  0,
259  (LPARAM)ShortDateSepSamples[nCBIndex]);
260  }
261 
262  /* Set current item to value from registry */
263  nRetCode = SendDlgItemMessageW(hwndDlg, IDC_SHRTDATESEP_COMBO,
265  -1,
266  (LPARAM)pGlobalData->szDateSep);
267 
268  /* If it is not successful, add new value to list and select them */
269  if (nRetCode == CB_ERR)
270  {
272  CB_ADDSTRING,
273  0,
274  (LPARAM)pGlobalData->szDateSep);
277  -1,
278  (LPARAM)pGlobalData->szDateSep);
279  }
280 }
uint16_t * PWSTR
Definition: typedefs.h:56
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT
Definition: typedefs.h:58
#define CB_ADDSTRING
Definition: winuser.h:1918
LONG_PTR LPARAM
Definition: windef.h:208
WCHAR szDateSep[MAX_DATESEPARATOR]
Definition: intl.h:101
#define CB_RESETCONTENT
Definition: winuser.h:1941
#define CB_ERR
Definition: winuser.h:2410
#define MAX_SHRT_DATE_SEPARATORS
Definition: date.c:32
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR L[]
Definition: oid.c:1250
#define CB_SELECTSTRING
Definition: winuser.h:1942
#define IDC_SHRTDATESEP_COMBO
Definition: resource.h:62

Referenced by DatePageProc().

◆ isDateCompAl()

BOOL isDateCompAl ( WCHAR  alpha)

Definition at line 43 of file date.c.

44 {
45  if ((alpha == L'y') || (alpha == L'M') || (alpha == L'd') || (alpha == L' '))
46  return TRUE;
47  else
48  return FALSE;
49 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const WCHAR L[]
Definition: oid.c:1250
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740

Referenced by FindDateSep(), SetLongDateFormat(), and SetShortDateFormat().

◆ SetLongDateFormat()

static BOOL SetLongDateFormat ( HWND  hwndDlg,
PWSTR  pszLongDateFmt 
)
static

Definition at line 193 of file date.c.

194 {
195  BOOL OpenApostFlg = FALSE;
196  INT nFmtStrSize;
197  INT nDateCompCount;
198 
199  /* Get format */
201  WM_GETTEXT,
203  (LPARAM)pszLongDateFmt);
204 
205  /* Get format string size */
206  nFmtStrSize = wcslen(pszLongDateFmt);
207 
208  /* Check date components */
209  for (nDateCompCount = 0; nDateCompCount < nFmtStrSize; nDateCompCount++)
210  {
211  if (pszLongDateFmt[nDateCompCount] == L'\'')
212  {
213  OpenApostFlg = !OpenApostFlg;
214  }
215 
216  if (iswalnum(pszLongDateFmt[nDateCompCount]) &&
217  !isDateCompAl(pszLongDateFmt[nDateCompCount]) &&
218  !OpenApostFlg)
219  {
221  return FALSE;
222  }
223  }
224 
225  if (OpenApostFlg || nFmtStrSize == 0)
226  {
228  return FALSE;
229  }
230 
231  return TRUE;
232 }
#define IDC_LONGDATEFMT_COMBO
Definition: resource.h:65
#define TRUE
Definition: types.h:120
#define WM_GETTEXT
Definition: winuser.h:1600
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define iswalnum(_c)
Definition: ctype.h:671
LONG_PTR LPARAM
Definition: windef.h:208
#define MAX_SAMPLES_STR_SIZE
Definition: intl.h:24
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR L[]
Definition: oid.c:1250
BOOL isDateCompAl(WCHAR alpha)
Definition: date.c:43
VOID PrintErrorMsgBox(UINT msg)
Definition: intl.c:52
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define IDS_ERROR_SYMBOL_FORMAT_LONG
Definition: resource.h:89

Referenced by GetDateSetting().

◆ SetMaxDate()

static VOID SetMaxDate ( HWND  hwndDlg,
LCID  lcid 
)
static

Definition at line 383 of file date.c.

384 {
385  WCHAR szMaxDateVal[YEAR_STR_MAX_SIZE];
386  HWND hWndYearSpin;
387  INT nSpinVal;
388 
389  hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
390 
391  /* Get spin value */
392  nSpinVal = LOWORD(SendMessageW(hWndYearSpin,
393  UDM_GETPOS,
394  0,
395  0));
396 
397  /* convert to wide char */
398  _itow(nSpinVal, szMaxDateVal, DECIMAL_RADIX);
399 
400  /* Save max date value */
401  SetCalendarInfoW(lcid,
403  48 , /* CAL_ITWODIGITYEARMAX */
404  (PCWSTR)szMaxDateVal);
405 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define UDM_GETPOS
Definition: commctrl.h:2140
_CRTIMP wchar_t *__cdecl _itow(_In_ int _Value, _Pre_notnull_ _Post_z_ wchar_t *_Dest, _In_ int _Radix)
#define IDC_SCR_MAX_YEAR
Definition: resource.h:56
int32_t INT
Definition: typedefs.h:58
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
int WINAPI SetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType, LPCWSTR lpCalData)
Definition: lcformat.c:2828
#define CAL_GREGORIAN
Definition: winnls.h:440
#define YEAR_STR_MAX_SIZE
Definition: date.c:31
#define DECIMAL_RADIX
Definition: intl.h:19
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LOWORD(l)
Definition: pedump.c:82

Referenced by DatePageProc().

◆ SetMinDate()

static VOID SetMinDate ( HWND  hwndDlg)
static

Definition at line 425 of file date.c.

426 {
428  HWND hWndYearSpin;
429  INT nSpinVal;
430 
431  hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
432 
433  /* Get spin value */
434  nSpinVal = LOWORD(SendMessageW(hWndYearSpin,
435  UDM_GETPOS,
436  0,
437  0));
438 
439  /* Set min year value */
440  wsprintf(OutBuffer, L"%d", (DWORD)nSpinVal - YEAR_DIFF);
442  WM_SETTEXT,
443  0,
444  (LPARAM)OutBuffer);
445 }
#define UDM_GETPOS
Definition: commctrl.h:2140
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
#define IDC_SCR_MAX_YEAR
Definition: resource.h:56
#define IDC_FIRSTYEAR_EDIT
Definition: resource.h:54
int32_t INT
Definition: typedefs.h:58
#define YEAR_DIFF
Definition: date.c:34
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define YEAR_STR_MAX_SIZE
Definition: date.c:31
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR L[]
Definition: oid.c:1250
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define wsprintf
Definition: winuser.h:5840
#define LOWORD(l)
Definition: pedump.c:82

Referenced by DatePageProc().

◆ SetShortDateFormat()

static BOOL SetShortDateFormat ( HWND  hwndDlg,
PWSTR  pszShortDateFmt 
)
static

Definition at line 125 of file date.c.

126 {
127  WCHAR szShortDateSep[MAX_SAMPLES_STR_SIZE];
128  WCHAR szFoundDateSep[MAX_SAMPLES_STR_SIZE];
129  PWSTR pszResultStr;
130  PWSTR pszFoundSep;
131  BOOL OpenApostFlg = FALSE;
132  INT nFmtStrSize;
133  INT nDateCompCount;
134 
135  /* Get format */
137  WM_GETTEXT,
139  (LPARAM)pszShortDateFmt);
140 
141  /* Get separator */
143  WM_GETTEXT,
145  (LPARAM)szShortDateSep);
146 
147  /* Get format-string size */
148  nFmtStrSize = wcslen(pszShortDateFmt);
149 
150  /* Check date components */
151  for (nDateCompCount = 0; nDateCompCount < nFmtStrSize; nDateCompCount++)
152  {
153  if (pszShortDateFmt[nDateCompCount] == L'\'')
154  {
155  OpenApostFlg = !OpenApostFlg;
156  }
157 
158  if (iswalnum(pszShortDateFmt[nDateCompCount]) &&
159  !isDateCompAl(pszShortDateFmt[nDateCompCount]) &&
160  !OpenApostFlg)
161  {
163  return FALSE;
164  }
165  }
166 
167  if (OpenApostFlg || nFmtStrSize == 0)
168  {
170  return FALSE;
171  }
172 
173  pszFoundSep = FindDateSep(pszShortDateFmt);
174  if (pszFoundSep != NULL)
175  {
176  /* Substring replacement of separator */
177  wcscpy(szFoundDateSep, pszFoundSep);
178  pszResultStr = ReplaceSubStr(pszShortDateFmt, szShortDateSep, szFoundDateSep);
179  if (pszResultStr != NULL)
180  {
181  wcscpy(pszShortDateFmt, pszResultStr);
182  HeapFree(GetProcessHeap(), 0, pszResultStr);
183  }
184 
185  HeapFree(GetProcessHeap(), 0, pszFoundSep);
186  }
187 
188  return TRUE;
189 }
PWSTR ReplaceSubStr(PCWSTR szSourceStr, PCWSTR szStrToReplace, PCWSTR szTempl)
Definition: misc.c:118
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
#define WM_GETTEXT
Definition: winuser.h:1600
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT
Definition: typedefs.h:58
#define IDS_ERROR_SYMBOL_FORMAT_SHORT
Definition: resource.h:88
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define iswalnum(_c)
Definition: ctype.h:671
LONG_PTR LPARAM
Definition: windef.h:208
#define MAX_SAMPLES_STR_SIZE
Definition: intl.h:24
#define GetProcessHeap()
Definition: compat.h:595
__wchar_t WCHAR
Definition: xmlstorage.h:180
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
BOOL isDateCompAl(WCHAR alpha)
Definition: date.c:43
LPTSTR FindDateSep(const WCHAR *szSourceStr)
Definition: date.c:53
#define IDC_SHRTDATEFMT_COMBO
Definition: resource.h:61
#define NULL
Definition: types.h:112
#define IDC_SHRTDATESEP_COMBO
Definition: resource.h:62
VOID PrintErrorMsgBox(UINT msg)
Definition: intl.c:52
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by GetDateSetting().

◆ SetShortDateSep()

static BOOL SetShortDateSep ( HWND  hwndDlg,
PWSTR  pszShortDateSep 
)
static

Definition at line 90 of file date.c.

91 {
92  INT nSepStrSize;
93  INT nSepCount;
94 
95  /* Get separator */
97  WM_GETTEXT,
99  (LPARAM)pszShortDateSep);
100 
101  /* Get separator string size */
102  nSepStrSize = wcslen(pszShortDateSep);
103 
104  /* Check date components */
105  for (nSepCount = 0; nSepCount < nSepStrSize; nSepCount++)
106  {
107  if (iswalnum(pszShortDateSep[nSepCount]) || (pszShortDateSep[nSepCount] == L'\''))
108  {
110  return FALSE;
111  }
112  }
113 
114  if (nSepStrSize == 0)
115  {
117  return FALSE;
118  }
119 
120  return TRUE;
121 }
#define IDS_ERROR_SYMBOL_SEPARATE
Definition: resource.h:87
#define TRUE
Definition: types.h:120
#define WM_GETTEXT
Definition: winuser.h:1600
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
#define iswalnum(_c)
Definition: ctype.h:671
LONG_PTR LPARAM
Definition: windef.h:208
#define MAX_SAMPLES_STR_SIZE
Definition: intl.h:24
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR L[]
Definition: oid.c:1250
#define IDC_SHRTDATESEP_COMBO
Definition: resource.h:62
VOID PrintErrorMsgBox(UINT msg)
Definition: intl.c:52
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by GetDateSetting().

◆ ShortDateFormatEnumProc()

static BOOL CALLBACK ShortDateFormatEnumProc ( PWSTR  lpTimeFormatString)
static

Definition at line 283 of file date.c.

284 {
286  CB_ADDSTRING,
287  0,
288  (LPARAM)lpTimeFormatString);
289 
290  return TRUE;
291 }
#define TRUE
Definition: types.h:120
#define CB_ADDSTRING
Definition: winuser.h:1918
LONG_PTR LPARAM
Definition: windef.h:208
static HWND hwndEnum
Definition: date.c:37
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by InitLongDateCB(), and InitShortDateCB().

◆ UpdateDateLocaleSamples()

static VOID UpdateDateLocaleSamples ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 496 of file date.c.

498 {
500 
501  /* Get short date format sample */
502  GetDateFormatW(pGlobalData->UserLCID, 0, NULL,
503  pGlobalData->szShortDateFormat, OutBuffer,
506  0, (LPARAM)OutBuffer);
507 
508  /* Get long date sample */
509  GetDateFormatW(pGlobalData->UserLCID, 0, NULL,
510  pGlobalData->szLongDateFormat, OutBuffer,
514 }
#define IDC_LONGDATESAMPLE_EDIT
Definition: resource.h:63
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
#define IDC_SHRTDATESAMPLE_EDIT
Definition: resource.h:59
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
#define MAX_SAMPLES_STR_SIZE
Definition: intl.h:24
WCHAR szLongDateFormat[MAX_LONGDATEFORMAT]
Definition: intl.h:99
__wchar_t WCHAR
Definition: xmlstorage.h:180
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
WCHAR szShortDateFormat[MAX_SHORTDATEFORMAT]
Definition: intl.h:100
#define NULL
Definition: types.h:112
LCID UserLCID
Definition: intl.h:113

Referenced by DatePageProc().

Variable Documentation

◆ hwndEnum

HWND hwndEnum = NULL
static

Definition at line 37 of file date.c.

Referenced by InitLongDateCB(), InitShortDateCB(), and ShortDateFormatEnumProc().