diff options
author | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-04-10 15:27:52 +0000 |
---|---|---|
committer | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-04-10 15:27:52 +0000 |
commit | 5cac46164a9dd8db435c01655454be96515ec882 (patch) | |
tree | 786669ab3f7d1274feb88db0bbc851f2d2662c95 /apps | |
parent | 69588c39343bef017758a402f523293afcc35da1 (diff) | |
download | rockbox-5cac46164a9dd8db435c01655454be96515ec882.tar.gz rockbox-5cac46164a9dd8db435c01655454be96515ec882.zip |
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
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gui/gwps-common.c | 24 | ||||
-rw-r--r-- | apps/gui/gwps.h | 8 |
2 files changed, 11 insertions, 21 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 4605b3461b..cdfea80fd4 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -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 diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h index e897413037..1d58f64768 100644 --- a/apps/gui/gwps.h +++ b/apps/gui/gwps.h @@ -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 */ |