- const wxChar *p = str.c_str();
- while ( *p )
- {
- if (wxIsdigit(*p))
- {
- int n=wxAtoi(p);
- if (n == dt.GetDay())
- {
- fmt.Append(wxT("%d"));
- day_cnt++;
- p += 2;
- }
- else if (n == (int)dt.GetMonth()+1)
- {
- fmt.Append(wxT("%m"));
- month_cnt++;
- p += 2;
- }
- else if (n == dt.GetYear())
- {
- fmt.Append(wxT("%Y"));
- year_cnt++;
- p += 4;
- }
- else if (n == (dt.GetYear() % 100))
- {
- if ( HasDPFlag(wxDP_SHOWCENTURY) )
- fmt.Append(wxT("%Y"));
- else
- fmt.Append(wxT("%y"));
- year_cnt++;
- p += 2;
- }
- else
- // this shouldn't happen
- return x_format;
- }
- else {
- fmt.Append(*p);
- p++;
- }
- }
-
- if (year_cnt == 1 && month_cnt == 1 && day_cnt == 1)
- return fmt;
-
- return x_format;