timme functs, not incorporated yet
This commit is contained in:
parent
dafa1ab97a
commit
6706f6a58e
46
Query.cpp
46
Query.cpp
@ -83,6 +83,36 @@ int query_role_customer(int id){
|
||||
|
||||
//------------------------------- 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) {
|
||||
for (Park_spot& i : parkspots) {
|
||||
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
|
||||
|
||||
#include "Park_spot.h"
|
||||
using std::pair;
|
||||
|
||||
/*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 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
|
||||
|
Loading…
Reference in New Issue
Block a user