Use valid_time() instead of using individual checks which amount to the same thing, and add RTC tokens beginning and end values that are used to check if a token is an RTC one.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13096 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
69588c3934
commit
5cac46164a
2 changed files with 11 additions and 21 deletions
|
@ -767,30 +767,12 @@ static char *get_token_value(struct gui_wps *gwps,
|
|||
|
||||
/* if the token is an RTC one, update the time and do the necessary checks */
|
||||
|
||||
if (token->type >= WPS_TOKEN_RTC_DAY_OF_MONTH
|
||||
&& token->type <= WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN)
|
||||
if (token->type >= WPS_TOKENS_RTC_BEGIN
|
||||
&& token->type <= WPS_TOKENS_RTC_END)
|
||||
{
|
||||
tm = get_time();
|
||||
|
||||
if (tm->tm_mday > 31 || tm->tm_mday < 1)
|
||||
return NULL;
|
||||
|
||||
if (tm->tm_hour > 23)
|
||||
return NULL;
|
||||
|
||||
if (tm->tm_mon > 11 || tm->tm_mon < 0)
|
||||
return NULL;
|
||||
|
||||
if (tm->tm_min > 59 || tm->tm_min < 0)
|
||||
return NULL;
|
||||
|
||||
if (tm->tm_sec > 59 || tm->tm_sec < 0)
|
||||
return NULL;
|
||||
|
||||
if (tm->tm_year > 199 || tm->tm_year < 100)
|
||||
return NULL;
|
||||
|
||||
if (tm->tm_wday > 6 || tm->tm_wday < 0)
|
||||
if (!valid_time(tm))
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -129,6 +129,12 @@ enum wps_token_type {
|
|||
|
||||
#if CONFIG_RTC
|
||||
/* Time */
|
||||
|
||||
/* The begin/end values allow us to know if a token is an RTC one.
|
||||
New RTC tokens should be added between the markers. */
|
||||
|
||||
WPS_TOKENS_RTC_BEGIN, /* just the start marker, not an actual token */
|
||||
|
||||
WPS_TOKEN_RTC_DAY_OF_MONTH,
|
||||
WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED,
|
||||
WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED,
|
||||
|
@ -146,6 +152,8 @@ enum wps_token_type {
|
|||
WPS_TOKEN_RTC_MONTH_NAME,
|
||||
WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON,
|
||||
WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN,
|
||||
|
||||
WPS_TOKENS_RTC_END, /* just the end marker, not an actual token */
|
||||
#endif
|
||||
|
||||
/* Conditional */
|
||||
|
|
Loading…
Reference in a new issue