static int get_current_tz_offset() { FILE* fp = fopen(TZ_FILE, "rb"); if (NULL == fp) { ST_ERRORPRINTF("Can't open %s, use default timezone settings.", TZ_FILE); goto error; } fseek(fp, sizeof(struct tzhead), SEEK_SET); int offset; if (fread(&offset, sizeof(int), 1, fp) != 1) { ST_ERRORPRINTF("Error reading %s, use default timezone settings.", TZ_FILE); fclose(fp); goto error; } fclose(fp); return GINT32_FROM_BE(offset); error: set_tz_offset(DEFAULT_TIMEZONE_NAME); return DEFAULT_TIMEZONE_OFFSET; }
/* Receive time zone information from the phone. */ static void in_received_handler( DictionaryIterator *data, void *context ) { Tuple *tuple = dict_find(data, APPMSG_KEY_TZ_OFFSET); /* Just bail here if this isn't the right type of data. */ if ( tuple == NULL || tuple->type != TUPLE_INT ) return; /* Update the offset. */ int32_t offset = tuple->value->int32; APP_LOG(APP_LOG_LEVEL_INFO, "Got offset %"PRId32" from phone.", offset); set_tz_offset(offset); }
void on_selection_update(erGtkSelectionGroup * selection, gpointer button, gpointer data) { int index = 0; ST_LOGPRINTF("entry"); ergtk_selection_group_get_selected_buttons(ERGTK_SELECTION_GROUP(selection), &index, 1); int tzoffset = timezones[index].tzoffset; // Update current timezone offset settings if (g_current_tz_offset != tzoffset) { g_current_tz_offset = tzoffset; // Update symbol link /mnt/settings/timezone // re-direct to the correct timezone file set_tz_offset(timezones[index].tzname); } // Update current date time displayed in the screen iLiad_update_datetime(g_current_tz_offset); }