diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index 1178f78..d251243 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -477,6 +477,7 @@ void MainWindow::get_calendar(){ } void MainWindow::calendar_show(){ + cout << 2222 << endl; if (year==0){ time_t now = time(0); tm *ltm = localtime(&now); @@ -556,8 +557,14 @@ void MainWindow::get_config(){ string cmd = "/usr/bin/ubconfig --source global get clock ZONE"; struct Result obj_result = this->wrapper_call(cmd); if (obj_result.error==0){ - auto arr_reg_zone_glob = this->split_region_zone(obj_result.response); - this->append_region_zone(arr_reg_zone_glob[0],arr_reg_zone_glob[1],cbRegionGlob,cbZoneGlob); + auto arr_reg_zone_glob = this->split_region_zone(obj_result.response); + if (arr_reg_zone_glob[0].length()!=0){ + this->append_region_zone(arr_reg_zone_glob[0],arr_reg_zone_glob[1],cbRegionGlob,cbZoneGlob); + } + else{ + this->append_region_zone("Africa","Abidjan", cbRegion, cbZone); + } + } else { this->append_region_zone("Africa","Abidjan",cbRegionGlob,cbZoneGlob); @@ -565,8 +572,13 @@ void MainWindow::get_config(){ cmd = "/usr/bin/ubconfig --source system get clock ZONE"; struct Result obj_result_1 = this->wrapper_call(cmd); if (obj_result_1.error==0){ - auto arr_reg_zone_glob = this->split_region_zone(obj_result_1.response); - this->append_region_zone(arr_reg_zone_glob[0],arr_reg_zone_glob[1], cbRegion, cbZone); + auto arr_reg_zone = this->split_region_zone(obj_result_1.response); + if (arr_reg_zone[0].length()!=0){ + this->append_region_zone(arr_reg_zone[0],arr_reg_zone[1], cbRegion, cbZone); + } + else{ + this->append_region_zone("Africa","Abidjan", cbRegion, cbZone); + } } else { this->append_region_zone("Africa","Abidjan", cbRegion, cbZone); @@ -574,11 +586,18 @@ void MainWindow::get_config(){ } array MainWindow::split_region_zone(string read_reg_zon_cfg){ - string str_filling_reg = read_reg_zon_cfg.substr(0,read_reg_zon_cfg.find("/")); - string str_filling_zon = read_reg_zon_cfg.substr(read_reg_zon_cfg.find("/")+1,read_reg_zon_cfg.length()); array arr; - arr[0] = str_filling_reg; - arr[1] = str_filling_zon; + if (read_reg_zon_cfg.find("/")!=std::string::npos){ + string str_filling_reg = read_reg_zon_cfg.substr(0,read_reg_zon_cfg.find("/")); + string str_filling_zon = read_reg_zon_cfg.substr(read_reg_zon_cfg.find("/")+1,read_reg_zon_cfg.length()); + + arr[0] = str_filling_reg; + arr[1] = str_filling_zon; + } + else{ + arr[0] = ""; + arr[1] = ""; + } return arr; }