mirror of
https://github.com/jorenchik/testing-spring-2024.git
synced 2025-10-21 20:10:36 +00:00
feat[prep]: room constructor
This commit is contained in:
parent
6df34b5529
commit
0c529ba023
@ -1,6 +1,7 @@
|
||||
#ifndef PREP_H
|
||||
#define PREP_H
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
@ -31,10 +32,22 @@ struct Player {
|
||||
};
|
||||
|
||||
struct Room {
|
||||
uint32_t id;
|
||||
std::string title;
|
||||
std::tm *utcTimestampCreatedAt;
|
||||
RoomStatus status;
|
||||
uint32_t id;
|
||||
|
||||
Room(uint32_t id, std::string title, uint32_t utcTimestampCreatedAt,
|
||||
RoomStatus status)
|
||||
: id(id), title(title), status(status) {
|
||||
// Convert the timestamp into a time_point object
|
||||
std::chrono::seconds sec(utcTimestampCreatedAt);
|
||||
std::chrono::time_point<std::chrono::system_clock> tp(sec);
|
||||
// Convert to time_t for formatting
|
||||
std::time_t time_object = std::chrono::system_clock::to_time_t(tp);
|
||||
// Convert to tm as UTC time
|
||||
this->utcTimestampCreatedAt = std::gmtime(&time_object);
|
||||
}
|
||||
};
|
||||
|
||||
struct Event {
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
#include "main_lib.h"
|
||||
#include "Prep.h"
|
||||
#include <iostream>
|
||||
|
||||
void run() { std::cout << add(2, 2) << std::endl; }
|
||||
void run() {
|
||||
Room room1(1, "Room 1", 1710087364, RoomStatus::IN_PROGRESS);
|
||||
Room room2(2, "Room 2", 1710087384, RoomStatus::ENDED);
|
||||
}
|
||||
|
||||
int functionToTest(int a) { return a * 2; }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user