From 5238b348c6d6ce3c1ab4303f96d459c7eee5e819 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Thu, 14 Mar 2024 01:01:19 +0200 Subject: [PATCH] refactor(time): move `time` to root --- src/lib.hh | 1 + src/prep/timeUtils.hh | 9 --------- src/room.cc | 6 ++++-- src/{prep/timeUtils.cc => time.cc} | 4 +--- src/time.hh | 9 +++++++++ 5 files changed, 15 insertions(+), 14 deletions(-) delete mode 100644 src/prep/timeUtils.hh rename src/{prep/timeUtils.cc => time.cc} (84%) create mode 100644 src/time.hh diff --git a/src/lib.hh b/src/lib.hh index a250d22..15d0946 100644 --- a/src/lib.hh +++ b/src/lib.hh @@ -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); diff --git a/src/prep/timeUtils.hh b/src/prep/timeUtils.hh deleted file mode 100644 index 74060e2..0000000 --- a/src/prep/timeUtils.hh +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -#ifndef TIMEUTILS_H -# define TIMEUTILS_H - -std::tm *createUTCTimestamp(uint32_t timestamp); - -#endif diff --git a/src/room.cc b/src/room.cc index a3dec91..d914c55 100644 --- a/src/room.cc +++ b/src/room.cc @@ -1,5 +1,7 @@ #include "room.hh" +#include "time.hh" + #include #include #include @@ -8,7 +10,7 @@ Room::Room(uint32_t id, std::string title, uint32_t created_at, RoomStatus status, std::vector 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 players): id(id), title(title), - created_at(createUTCTimestamp(created_at)), + created_at(create_utc_timestamp(created_at)), status(status), players(players) { } diff --git a/src/prep/timeUtils.cc b/src/time.cc similarity index 84% rename from src/prep/timeUtils.cc rename to src/time.cc index e52033c..155abc5 100644 --- a/src/prep/timeUtils.cc +++ b/src/time.cc @@ -1,10 +1,8 @@ -#include "timeUtils.hh" - #include #include #include -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 tp(sec); diff --git a/src/time.hh b/src/time.hh new file mode 100644 index 0000000..3a746e5 --- /dev/null +++ b/src/time.hh @@ -0,0 +1,9 @@ +#ifndef TIME_HH +#define TIME_HH + +#include +#include + +std::tm *create_utc_timestamp(uint32_t timestamp); + +#endif // !TIME_HH