mirror of
https://github.com/jorenchik/testing-spring-2024.git
synced 2025-10-21 20:10:36 +00:00
refactor(time): move time to root
This commit is contained in:
parent
cad8e6d032
commit
5238b348c6
@ -2,6 +2,7 @@
|
||||
#include "player.hh"
|
||||
#include "prep/prep.hh"
|
||||
#include "role.hh"
|
||||
#include "room.hh"
|
||||
|
||||
bool playerBelongsToRoom(Player *player, Room *room);
|
||||
bool actionBelongsToRole(Role *role, const Action *action);
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
|
||||
#ifndef TIMEUTILS_H
|
||||
# define TIMEUTILS_H
|
||||
|
||||
std::tm *createUTCTimestamp(uint32_t timestamp);
|
||||
|
||||
#endif
|
||||
@ -1,5 +1,7 @@
|
||||
#include "room.hh"
|
||||
|
||||
#include "time.hh"
|
||||
|
||||
#include <cstdint>
|
||||
#include <initializer_list>
|
||||
#include <string>
|
||||
@ -8,7 +10,7 @@
|
||||
Room::Room(uint32_t id, std::string title, uint32_t created_at, RoomStatus status, std::vector<Player> players):
|
||||
id(id),
|
||||
title(title),
|
||||
created_at(createUTCTimestamp(created_at)),
|
||||
created_at(create_utc_timestamp(created_at)),
|
||||
status(status),
|
||||
players(players) {
|
||||
}
|
||||
@ -17,7 +19,7 @@ Room::Room(
|
||||
uint32_t id, std::string title, uint32_t created_at, RoomStatus status, std::initializer_list<Player> players):
|
||||
id(id),
|
||||
title(title),
|
||||
created_at(createUTCTimestamp(created_at)),
|
||||
created_at(create_utc_timestamp(created_at)),
|
||||
status(status),
|
||||
players(players) {
|
||||
}
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
#include "timeUtils.hh"
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
|
||||
std::tm *createUTCTimestamp(uint32_t timestamp) {
|
||||
std::tm *create_utc_imestamp(uint32_t timestamp) {
|
||||
// Convert the timestamp into a time_point object
|
||||
std::chrono::seconds sec(timestamp);
|
||||
std::chrono::time_point<std::chrono::system_clock> tp(sec);
|
||||
9
src/time.hh
Normal file
9
src/time.hh
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef TIME_HH
|
||||
#define TIME_HH
|
||||
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
|
||||
std::tm *create_utc_timestamp(uint32_t timestamp);
|
||||
|
||||
#endif // !TIME_HH
|
||||
Loading…
Reference in New Issue
Block a user