bool CDirList::IsTimeStamp(const wxString &s) { bool bRtn = true; if(s.Len() != 15) { bRtn = false; } else if(s.GetChar(8) != '_') { bRtn = false; } else if(!nwxString::IsInteger(s.Left(8),false)) { bRtn = false; } else if(!nwxString::IsInteger(s.Right(6),false)) { bRtn = false; } else { #define BETWEEN(n,min,max) ((n >= min) && (n <= max)) int nY = atoi(s.Left(4).utf8_str()); int nM = atoi(s.Mid(4,2).utf8_str()); int nD = atoi(s.Mid(6,2).utf8_str()); int nHH = atoi(s.Mid(9,2).utf8_str()); int nMM = atoi(s.Mid(11,2).utf8_str()); int nSS = atoi(s.Mid(13,2).utf8_str()); // check year to see if newer than this software if( !BETWEEN(nY,2011,2099) ) { bRtn = false; } else if( !BETWEEN(nM,1,12) ) { bRtn = false; } else if( !BETWEEN(nD,1,MaxDayOfMonth(nY,nM)) ) { bRtn = false; } else if( !BETWEEN(nHH,0,23) ) { bRtn = false; } else if(! BETWEEN(nMM,0,59) ) { bRtn = false; } else if(! BETWEEN(nSS,0,59) ) { bRtn = false; } } #undef BETWEEN return bRtn; }
//***************************************************************************** // //! Handle the DOWN button event. //! //! \param psWidget is a pointer to the clock setting widget on which to //! operate. //! //! This function handles the event when the user has pressed the down button. //! It will decrement the currently highlighted date/time field if it is not //! already at the minimum value. If the month is being changed then it //! enforces the maximum number of days for the month. //! //! \return Returns non-zero if the button event was handled, and 0 if the //! button event was not handled. // //***************************************************************************** static int32_t ClockSetKeyDown(tClockSetWidget *psWidget) { // // Get pointer to the time structure to be modified. // struct tm *psTime = psWidget->psTime; // // Determine which field is highlighted. // switch(psWidget->ui32Highlight) { // // Decrement the year. Minimum year is 1970. // case FIELD_YEAR: { if(psTime->tm_year+1900 > 1970) { psTime->tm_year--; } break; } // // Decrement the month. If the month has changed, check that the // day is valid for this month, and enforce the maximum day number // for this month. // case FIELD_MONTH: { if(psTime->tm_mon > 0) { psTime->tm_mon--; } if(psTime->tm_mday > MaxDayOfMonth(psTime->tm_mon)) { psTime->tm_mday = MaxDayOfMonth(psTime->tm_mon); } break; } // // Decrement the day // case FIELD_DAY: { if(psTime->tm_mday > 1) { psTime->tm_mday--; } break; } // // Decrement the hour // case FIELD_HOUR: { if(psTime->tm_hour > 0) { psTime->tm_hour--; } break; } // // Decrement the minute // case FIELD_MINUTE: { if(psTime->tm_min > 0) { psTime->tm_min--; } break; } // // Bad value for field index - ignore. // default: { break; } } // // Since something may have been changed in the clock value, request // a repaint of the widget. // WidgetPaint(&psWidget->sBase); // // Return indication that the button event was handled. // return(1); }
//***************************************************************************** // //! Handle the UP button event. //! //! \param psWidget is a pointer to the clock setting widget on which to //! operate. //! //! This function handles the event when the user has pressed the up button. //! It will increment the currently highlighted date/time field if it is not //! already at the maximum value. If the month or day of the month is being //! changed then it enforces the maximum number of days for the month. //! //! \return Returns non-zero if the button event was handled, and 0 if the //! button event was not handled. // //***************************************************************************** static int32_t ClockSetKeyUp(tClockSetWidget *psWidget) { // // Get pointer to the time structure to be modified. // struct tm *psTime = psWidget->psTime; // // Determine which field is highlighted. // switch(psWidget->ui32Highlight) { // // Increment the year. Cap it at 2037 to keep things simple. // case FIELD_YEAR: { if(psTime->tm_year+1900 < 2037) { psTime->tm_year++; } break; } // // Increment the month. Adjust the day of the month if needed. // case FIELD_MONTH: { if(psTime->tm_mon < 11) { psTime->tm_mon++; } if(psTime->tm_mday > MaxDayOfMonth(psTime->tm_mon)) { psTime->tm_mday = MaxDayOfMonth(psTime->tm_mon); } break; } // // Increment the day. Cap it at the max number of days for the // current value of month. // case FIELD_DAY: { if(psTime->tm_mday < MaxDayOfMonth(psTime->tm_mon)) { psTime->tm_mday++; } break; } // // Increment the hour. // case FIELD_HOUR: { if(psTime->tm_hour < 23) { psTime->tm_hour++; } break; } // // Increment the minute. // case FIELD_MINUTE: { if(psTime->tm_min < 59) { psTime->tm_min++; } break; } // // Bad value for field index - ignore. // default: { break; } } // // Since something may have been changed in the clock value, request // a repaint of the widget. // WidgetPaint(&psWidget->sBase); // // Return indication that the button event was handled. // return(1); }