From e3c225dbf1a80790b1298034ff0c77f97bb6ea4f Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Tue, 14 Feb 2023 12:47:23 +0600 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=20=D0=B7?= =?UTF-8?q?=D0=BE=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 53 +++++++++++++++++++++++++++++++-- source/ubl-settings-datetime.h | 1 + ubl-settings-datetime_ru.po | 3 ++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index ac46b29..51f356d 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -338,7 +338,6 @@ bool MainWindow::focus_ntp(GdkEventFocus* event){ string str_ntp = txtNtpServer->get_text(); for (const auto &simvol: array_simvol){ if (str_ntp.find(simvol)!=std::string::npos){ - cout << simvol << 2222 << endl; flag_error=true; break; @@ -450,7 +449,6 @@ void MainWindow::calendar_show(){ void MainWindow::enry_dhcp_mess(){ string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS"); - cout << str_dhcp << endl; if (str_dhcp.find("(null)")==std::string::npos){ cbxSynchronizeNtpGlob->set_active(true); @@ -843,6 +841,7 @@ void MainWindow::read_file(){ } in1.close(); } + this->sort_zone(&zone_local, &zone); time_reg_map.insert({key_reg, zone}); time_reg_map_local.insert({key_reg, zone_local}); }}}} @@ -852,6 +851,56 @@ void MainWindow::read_file(){ } } +void MainWindow::sort_zone(vector *time_reg_map_local,vector *time_reg_map){ + string str_j = ""; + int j_i; + string str_j_1 = ""; + int j_i_1; + int size_vec = time_reg_map_local->size(); + for (int i = 0; i < size_vec; i++) { + for (int j = 0; j < size_vec-1; j++) { + str_j=(*time_reg_map_local)[j]; + str_j = str_j.substr(5,str_j.find(")")-5); + if (str_j[1]=='0'){ + str_j.replace(1,1,"0"); + } + + if (str_j.find("+") != std::string::npos){ + str_j.replace(0,1,"+"); + j_i = stoi(str_j); + } + else{ + str_j.replace(0,1,"-"); + j_i = stoi(str_j); + j_i=-j_i; + } + str_j_1=(*time_reg_map_local)[j+1]; + str_j_1 = str_j_1.substr(5,str_j_1.find(")")-5); + if (str_j_1[1]=='0'){ + str_j_1.replace(1,1,"0"); + } + if (str_j_1.find("+") != std::string::npos){ + str_j_1.replace(0,1,"+"); + j_i_1 = stoi(str_j_1); + } + else{ + str_j_1.replace(0,1,"-"); + j_i_1 = stoi(str_j_1); + j_i_1 = -j_i_1; + } + if (j_i > j_i_1) { + string b = (*time_reg_map_local)[j]; + (*time_reg_map_local)[j] = (*time_reg_map_local)[j + 1]; + (*time_reg_map_local)[j + 1] = b; + + b = (*time_reg_map)[j]; + (*time_reg_map)[j] = (*time_reg_map)[j + 1]; + (*time_reg_map)[j + 1] = b; + } + } + } +} + string MainWindow::zone_file_read(string zone){ if (zone.length()==1){ return ""; diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h index d55f61d..e72a8b1 100644 --- a/source/ubl-settings-datetime.h +++ b/source/ubl-settings-datetime.h @@ -72,6 +72,7 @@ class MainWindow : public Gtk::ApplicationWindow { void wind_close_ntp(); void wrapper_update_time_date(); string zone_file_read(string zone); + void sort_zone(vector *time_reg_map_local,vector *time_reg_map); array split_region_zone(string read_reg_zon_cfg); string str_remove(std::string& source, const std::string to_remove); vector split(const std::string &s, char delim); diff --git a/ubl-settings-datetime_ru.po b/ubl-settings-datetime_ru.po index deadb04..e725dbd 100644 --- a/ubl-settings-datetime_ru.po +++ b/ubl-settings-datetime_ru.po @@ -1609,3 +1609,6 @@ msgstr "Южная Нижняя Калифорния" msgid "Enter the name of the ntp-server or its ip-address.\nWhen entering multiple addresses, separate them with commas." msgstr "Введите имя ntp-сервера или его ip-адрес.\nПри вводе нескольких адресов, разделяйте их запятыми." +msgid "Cape_Verde" +msgstr "Кабо-Верде" +