-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdatetime.cpp
More file actions
36 lines (24 loc) · 1.01 KB
/
datetime.cpp
File metadata and controls
36 lines (24 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <QTextStream>
#include <QDate>
#include <QTime>
#include "mainwindow.h"
#include "ui_mainwindow.h"
QString MainWindow::get_date_time (QString format){
QString buff = 0;
QTextStream out(stdout);
//out.setCodec("CP866"); // устанавливаем CP866-кодировку для консоли
QDate cd = QDate::currentDate(); // возвращаем текущую дату
QTime ct = QTime::currentTime(); // возвращаем текущее время
// out << cd.toString("dd-MM-yyyy") << endl; // в качестве разделителя используем дефис
// out << ct.toString("hh:mm:ss.zzz")<< endl;
if (ui->checkBox_datatime->isChecked()){
ui->textBrowser->setTextColor(QColor(102, 178, 255));
if (ui->radioButton_datim->isChecked()){
buff = cd.toString("yyyy-MM-dd") + " " + ct.toString("hh:mm:ss.zzz") + "\n";
}
else {
buff = ct.toString("hh:mm:ss.zzz") + "\n";
}
}
return buff;
}