From 7d5db322dd31b251cf91c77dee166759ccc11aee Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 15 Feb 2023 12:19:28 +0600 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=81=D0=BB=D0=B5=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 35 +++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) 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; }