added new way to get time, should not need seperate versions of Daily Bread now. Same method works for both Linux and Windows.
This commit is contained in:
parent
d645996ab6
commit
309b1c7085
@ -9,9 +9,11 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "./ui_mainwindow.h"
|
#include "./ui_mainwindow.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <ctime>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
int current_day();
|
||||||
|
int current_month();
|
||||||
|
|
||||||
QString verse_display();
|
QString verse_display();
|
||||||
std::string verse_grab();
|
std::string verse_grab();
|
||||||
@ -23,6 +25,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->verse->setText(verse_display());
|
ui->verse->setText(verse_display());
|
||||||
|
std::cout << current_day();
|
||||||
|
std::cout << current_month();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -49,16 +53,52 @@ QString verse_display()
|
|||||||
std::string verse_grab(){
|
std::string verse_grab(){
|
||||||
|
|
||||||
std::string my_verse;
|
std::string my_verse;
|
||||||
|
int curmonth = current_month();
|
||||||
|
int curday = current_day();
|
||||||
|
|
||||||
return my_verse;
|
std::string query = "select * from verses where day = " + std::to_string(curday) + " and month = " + std::to_string(curmonth);
|
||||||
|
|
||||||
|
|
||||||
|
my_verse = "hello world!";
|
||||||
|
return query;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_exitButton_clicked()
|
void MainWindow::on_exitButton_clicked()
|
||||||
{
|
{
|
||||||
QApplication::quit();
|
QApplication::quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Everything below this grabs the day and month.
|
||||||
|
typedef std::chrono::system_clock Clock;
|
||||||
|
int current_day(){
|
||||||
|
|
||||||
|
auto now = Clock::now();
|
||||||
|
std::time_t now_c = Clock::to_time_t(now);
|
||||||
|
struct tm *parts = std::localtime(&now_c);
|
||||||
|
|
||||||
|
|
||||||
|
int day = parts->tm_mday;
|
||||||
|
|
||||||
|
return day;
|
||||||
|
}
|
||||||
|
|
||||||
|
int current_month(){
|
||||||
|
|
||||||
|
auto now = Clock::now();
|
||||||
|
std::time_t now_c = Clock::to_time_t(now);
|
||||||
|
struct tm *parts = std::localtime(&now_c);
|
||||||
|
|
||||||
|
|
||||||
|
int month = 1 + parts->tm_mon;
|
||||||
|
|
||||||
|
return month;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user