diff options
author | Nils Wallménius <nils@rockbox.org> | 2008-04-20 21:01:39 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2008-04-20 21:01:39 +0000 |
commit | ac1b30ef7351fdda552dede1cd08add823ca602c (patch) | |
tree | dae8645c655ced331c7e289b335266dff6e485aa | |
parent | 380e9154288b22350102848a2941e0458e921623 (diff) | |
download | rockbox-ac1b30ef7351fdda552dede1cd08add823ca602c.tar.gz rockbox-ac1b30ef7351fdda552dede1cd08add823ca602c.zip |
Nicer handling of unset clock in the 'Rockbox Info' screen
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17199 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/lang/english.lang | 14 | ||||
-rw-r--r-- | apps/menus/main_menu.c | 62 |
2 files changed, 62 insertions, 14 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 6a793711c2..d288d045ec 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -11590,3 +11590,17 @@ | |||
11590 | *: "Accessory Power Supply" | 11590 | *: "Accessory Power Supply" |
11591 | </voice> | 11591 | </voice> |
11592 | </phrase> | 11592 | </phrase> |
11593 | <phrase> | ||
11594 | id: LANG_UNKNOWN | ||
11595 | desc: generic string for unknown states, such as an unset clock | ||
11596 | user: | ||
11597 | <source> | ||
11598 | *: "Unknown" | ||
11599 | </source> | ||
11600 | <dest> | ||
11601 | *: "Unknown" | ||
11602 | </dest> | ||
11603 | <voice> | ||
11604 | *: "Unknown" | ||
11605 | </voice> | ||
11606 | </phrase> | ||
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index 39f722f2c6..8e4ee61aee 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c | |||
@@ -183,20 +183,34 @@ static char* info_getname(int selected_item, void *data, | |||
183 | #if CONFIG_RTC | 183 | #if CONFIG_RTC |
184 | case INFO_TIME: | 184 | case INFO_TIME: |
185 | tm = get_time(); | 185 | tm = get_time(); |
186 | snprintf(buffer, buffer_len, "%02d:%02d:%02d %s", | 186 | if (valid_time(tm)) |
187 | global_settings.timeformat == 0 ? tm->tm_hour : | 187 | { |
188 | ((tm->tm_hour + 11) % 12) + 1, | 188 | snprintf(buffer, buffer_len, "%02d:%02d:%02d %s", |
189 | tm->tm_min, | 189 | global_settings.timeformat == 0 ? tm->tm_hour : |
190 | tm->tm_sec, | 190 | ((tm->tm_hour + 11) % 12) + 1, |
191 | global_settings.timeformat == 0 ? "" : | 191 | tm->tm_min, |
192 | tm->tm_hour>11 ? "P" : "A"); | 192 | tm->tm_sec, |
193 | global_settings.timeformat == 0 ? "" : | ||
194 | tm->tm_hour>11 ? "P" : "A"); | ||
195 | } | ||
196 | else | ||
197 | { | ||
198 | snprintf(buffer, buffer_len, "%s", "--:--:--"); | ||
199 | } | ||
193 | break; | 200 | break; |
194 | case INFO_DATE: | 201 | case INFO_DATE: |
195 | tm = get_time(); | 202 | tm = get_time(); |
196 | snprintf(buffer, buffer_len, "%s %d %d", | 203 | if (valid_time(tm)) |
197 | str(LANG_MONTH_JANUARY + tm->tm_mon), | 204 | { |
198 | tm->tm_mday, | 205 | snprintf(buffer, buffer_len, "%s %d %d", |
199 | tm->tm_year+1900); | 206 | str(LANG_MONTH_JANUARY + tm->tm_mon), |
207 | tm->tm_mday, | ||
208 | tm->tm_year+1900); | ||
209 | } | ||
210 | else | ||
211 | { | ||
212 | snprintf(buffer, buffer_len, "%s", str(LANG_UNKNOWN)); | ||
213 | } | ||
200 | break; | 214 | break; |
201 | #endif | 215 | #endif |
202 | case INFO_BUFFER: /* buffer */ | 216 | case INFO_BUFFER: /* buffer */ |
@@ -270,6 +284,10 @@ static int info_speak_item(int selected_item, void * data) | |||
270 | { | 284 | { |
271 | struct info_data *info = (struct info_data*)data; | 285 | struct info_data *info = (struct info_data*)data; |
272 | 286 | ||
287 | #if CONFIG_RTC | ||
288 | struct tm *tm; | ||
289 | #endif | ||
290 | |||
273 | switch (selected_item) | 291 | switch (selected_item) |
274 | { | 292 | { |
275 | case INFO_VERSION: /* version */ | 293 | case INFO_VERSION: /* version */ |
@@ -277,12 +295,28 @@ static int info_speak_item(int selected_item, void * data) | |||
277 | talk_spell(appsversion, true); | 295 | talk_spell(appsversion, true); |
278 | break; | 296 | break; |
279 | #if CONFIG_RTC | 297 | #if CONFIG_RTC |
280 | case INFO_TIME: | 298 | case INFO_TIME: |
299 | tm = get_time(); | ||
281 | talk_id(VOICE_CURRENT_TIME, false); | 300 | talk_id(VOICE_CURRENT_TIME, false); |
282 | talk_time(get_time(), true); | 301 | if (valid_time(tm)) |
302 | { | ||
303 | talk_time(tm, true); | ||
304 | } | ||
305 | else | ||
306 | { | ||
307 | talk_id(LANG_UNKNOWN, true); | ||
308 | } | ||
283 | break; | 309 | break; |
284 | case INFO_DATE: | 310 | case INFO_DATE: |
285 | talk_date(get_time(), true); | 311 | tm = get_time(); |
312 | if (valid_time(tm)) | ||
313 | { | ||
314 | talk_date(get_time(), true); | ||
315 | } | ||
316 | else | ||
317 | { | ||
318 | talk_id(LANG_UNKNOWN, true); | ||
319 | } | ||
286 | break; | 320 | break; |
287 | #endif | 321 | #endif |
288 | case INFO_BUFFER: /* buffer */ | 322 | case INFO_BUFFER: /* buffer */ |