nicer time zone names on new LCD
This commit is contained in:
parent
af094e2c2d
commit
d35a3ee8d1
@ -169,7 +169,7 @@ static bool _world_clock_face_do_settings_mode(movement_event_t event, world_clo
|
||||
sprintf(buf, "%c%c %s",
|
||||
movement_valid_position_0_chars[state->settings.bit.char_0],
|
||||
movement_valid_position_1_chars[state->settings.bit.char_1],
|
||||
(char *) (zone_names + 8 * state->settings.bit.timezone_index));
|
||||
watch_utility_time_zone_name_at_index(state->settings.bit.timezone_index));
|
||||
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||
|
||||
// blink up the parameter we're setting
|
||||
|
||||
@ -140,7 +140,7 @@ bool set_time_face_loop(movement_event_t event, void *context) {
|
||||
sprintf(buf, "%2d%02d ", hours % 100, minutes % 100);
|
||||
watch_set_colon();
|
||||
} else {
|
||||
sprintf(buf, "%s", (char *) (zone_names + 8 * movement_get_timezone_index()));
|
||||
sprintf(buf, "%s", watch_utility_time_zone_name_at_index(movement_get_timezone_index()));
|
||||
watch_clear_colon();
|
||||
}
|
||||
} else if (current_page < 4) {
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
|
||||
#include <math.h>
|
||||
#include "watch_utility.h"
|
||||
#include "zones.h"
|
||||
|
||||
const char * watch_utility_get_weekday(watch_date_time_t date_time) {
|
||||
static const char weekdays[7][3] = {"MO", "TU", "WE", "TH", "FR", "SA", "SU"};
|
||||
@ -328,3 +329,71 @@ uint8_t watch_utility_days_in_month(uint8_t month, uint16_t year) {
|
||||
days += 1;
|
||||
return days;
|
||||
}
|
||||
|
||||
char _scratch_timezone[7] = {0};
|
||||
|
||||
char *watch_utility_time_zone_name_at_index(int32_t tzindex) {
|
||||
char *zone_in_rom = (zone_names + 8 * tzindex);
|
||||
|
||||
if (watch_get_lcd_type() != WATCH_LCD_TYPE_CUSTOM) {
|
||||
// classic LCD can get a pointer to ROM
|
||||
return zone_in_rom;
|
||||
} else {
|
||||
// otherwise handle tweaks for custom LCD
|
||||
strncpy(_scratch_timezone, zone_in_rom, 7);
|
||||
|
||||
// D, B and T can all be displayed in position 1
|
||||
if (_scratch_timezone[0] == 'D') _scratch_timezone[0] = 'd';
|
||||
if (_scratch_timezone[0] == 'B') _scratch_timezone[0] = 'b';
|
||||
if (_scratch_timezone[0] == '+') _scratch_timezone[0] = 't';
|
||||
|
||||
// Fake M had to be lowercase before; now can be uppercase.
|
||||
if (_scratch_timezone[0] == 'n' && _scratch_timezone[1] == '&') {
|
||||
_scratch_timezone[0] = 'N';
|
||||
_scratch_timezone[1] = '7';
|
||||
}
|
||||
|
||||
// Other edgier cases:
|
||||
switch (tzindex) {
|
||||
case 8: // New York
|
||||
strncpy(_scratch_timezone, "NuYork", 7);
|
||||
break;
|
||||
case 13: // St John's
|
||||
_scratch_timezone[2] = 'J';
|
||||
_scratch_timezone[3] = 'o';
|
||||
_scratch_timezone[4] = 'h';
|
||||
_scratch_timezone[5] = 'n';
|
||||
break;
|
||||
case 15: // UTC
|
||||
strncpy(_scratch_timezone, " UTC ", 7);
|
||||
break;
|
||||
case 16: // London
|
||||
strncpy(_scratch_timezone, "London", 7);
|
||||
break;
|
||||
case 17: // Lagos
|
||||
strncpy(_scratch_timezone, "Lagos ", 7);
|
||||
break;
|
||||
case 24: // Riyadh
|
||||
strncpy(_scratch_timezone, "Riyadh", 7);
|
||||
break;
|
||||
case 25: // Moscow
|
||||
_scratch_timezone[4] = 'O';
|
||||
_scratch_timezone[5] = 'W';
|
||||
break;
|
||||
case 30: // Yangon / Burma
|
||||
strncpy(_scratch_timezone, " burma", 7);
|
||||
break;
|
||||
case 41: // Hobart
|
||||
strncpy(_scratch_timezone, "Hobart", 7);
|
||||
break;
|
||||
case 42: // Sydney
|
||||
_scratch_timezone[2] = 'd';
|
||||
break;
|
||||
case 43: // Guam
|
||||
_scratch_timezone[4] = 'M';
|
||||
_scratch_timezone[5] = ' ';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return _scratch_timezone;
|
||||
}
|
||||
|
||||
@ -174,4 +174,9 @@ uint32_t watch_utility_offset_timestamp(uint32_t now, int8_t hours, int8_t minut
|
||||
*/
|
||||
uint8_t watch_utility_days_in_month(uint8_t month, uint16_t year);
|
||||
|
||||
/** @brief Returns a null-terminated six-character string representing the time zone name at a given index.
|
||||
* @param tzindex The index of the time zone
|
||||
*/
|
||||
char * watch_utility_time_zone_name_at_index(int32_t tzindex);
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user