Timefuctions to get reports from any time after 1970 #10
46
Query.cpp
46
Query.cpp
@ -83,6 +83,36 @@ int query_role_customer(int id){
|
|||||||
|
|
||||||
//------------------------------- parkspot info
|
//------------------------------- parkspot info
|
||||||
|
|
||||||
|
|
||||||
|
pair<int, int> create_month_period(int month, int year) {
|
||||||
|
std::time_t t = std::time(0);
|
||||||
|
std::tm* date = std::localtime(&t);
|
||||||
|
date->tm_year = year - 1900;
|
||||||
|
date->tm_mday = 1;
|
||||||
|
date->tm_mon = month - 1;
|
||||||
|
pair<int, int> period;
|
||||||
|
period.first = mktime(date);
|
||||||
|
date->tm_mon = month;
|
||||||
|
period.second = mktime(date);
|
||||||
|
return period;
|
||||||
|
}
|
||||||
|
|
||||||
|
pair<int, int> create_week_period(int day, int month, int year){
|
||||||
|
std::time_t t = std::time(0);
|
||||||
|
std::tm* date = std::localtime(&t);
|
||||||
|
date->tm_year = year - 1900;
|
||||||
|
date->tm_mday = day;
|
||||||
|
date->tm_mon = month - 1;
|
||||||
|
date->tm_hour = 0;
|
||||||
|
date->tm_min = 0;
|
||||||
|
pair<int, int> period;
|
||||||
|
period.first = mktime(date);
|
||||||
|
period.second = period.first + 604800; // plus 7 days in seconds
|
||||||
|
return period;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- parkspots info, report gen
|
||||||
|
|
||||||
Park_spot query_parkspot_with_id(int id, vector<Park_spot>& parkspots) {
|
Park_spot query_parkspot_with_id(int id, vector<Park_spot>& parkspots) {
|
||||||
for (Park_spot& i : parkspots) {
|
for (Park_spot& i : parkspots) {
|
||||||
if (i.id == id) {
|
if (i.id == id) {
|
||||||
@ -163,19 +193,3 @@ void current_status_parkspots(vector<Park_spot>& spots) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------- paroking spots
|
|
||||||
|
|
||||||
// vector<Park_spot> populate_spots(){
|
|
||||||
// vector<Park_spot> spots;
|
|
||||||
// SQLite::Statement query(data::db, "SELECT * FROM Park_spot WHERE id >
|
|
||||||
// 0;");
|
|
||||||
// // query.bind(1, 2);
|
|
||||||
// while (query.executeStep()) {
|
|
||||||
// int id = query.getColumn(0);
|
|
||||||
// int taken = query.getColumn(1);
|
|
||||||
// int cid = query.getColumn(2);
|
|
||||||
// // park_customers.push_back(query_customer_with_id(cid));
|
|
||||||
// spots.push_back({id, taken, cid});
|
|
||||||
// }
|
|
||||||
// return spots;
|
|
||||||
// }
|
|
@ -3,6 +3,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Park_spot.h"
|
#include "Park_spot.h"
|
||||||
|
using std::pair;
|
||||||
|
|
||||||
/*these are the functions that search the database and create objects from it.
|
/*these are the functions that search the database and create objects from it.
|
||||||
|
|
||||||
@ -65,4 +66,7 @@ void reports_from_parkspot(int spotid, bool weekly = false);
|
|||||||
void reports_from_allparkspots(bool weekly = false);
|
void reports_from_allparkspots(bool weekly = false);
|
||||||
|
|
||||||
void current_status_parkspots(vector<Park_spot>& spots);
|
void current_status_parkspots(vector<Park_spot>& spots);
|
||||||
|
|
||||||
|
pair<int, int> create_month_period(int month, int year) ;
|
||||||
|
pair<int, int> create_week_period(int day, int month, int year);
|
||||||
#endif // CUSTOMER_H
|
#endif // CUSTOMER_H
|
||||||
|
Loading…
Reference in New Issue
Block a user