File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 7
7
#include < string>
8
8
#include < vector>
9
9
#include < cmath>
10
- #include < QDebug >
10
+ #include < iomanip >
11
11
12
12
MainWindow::MainWindow (QWidget *parent) {
13
13
ui.setupUi (this );
@@ -256,8 +256,14 @@ void MainWindow::populate_fields(Item item) {
256
256
bool usedInLastSixMonths = item.usedInLastSixMonths ;
257
257
std::string notes = item.notes ;
258
258
259
- std::string date_from_db = std::to_string (purchase_day) + " /" + std::to_string (purchase_month) + " /" + std::to_string (purchase_year);
259
+ std::ostringstream month_padded;
260
+ std::ostringstream day_padded;
261
+ month_padded << std::setw (2 ) << std::setfill (' 0' ) << purchase_month;
262
+ day_padded << std::setw (2 ) << std::setfill (' 0' ) << purchase_day;
263
+
264
+ std::string date_from_db = day_padded.str () + " /" + month_padded.str () + " /" + std::to_string (purchase_year);
260
265
QDate date = QDate::fromString (QString::fromUtf8 (date_from_db.c_str ()), " dd/MM/yyyy" );
266
+ std::cout << " Date: " << date_from_db << std::endl;
261
267
262
268
ui.ItemName ->setText (QString::fromStdString (item_name));
263
269
ui.ItemCategory ->setCurrentText (QString::fromStdString (item_category));
You can’t perform that action at this time.
0 commit comments