Nui Engine
A game engine framework
Loading...
Searching...
No Matches
Timestamp.h
1#pragma once
2#include "Core/Common/Types.h"
3
4namespace Nui
5{
10 {
11 public:
12 using ClockType = chrono::system_clock;
13 using TimePoint = ClockType::time_point;
14
19 : m_point(ClockType::now())
20 {}
21
25 Timestamp(const TimePoint& point)
26 : m_point(point)
27 {}
28
33 String GetDateAndTime() const
34 {
35 const auto time = chrono::current_zone()->to_local(m_point);
36 return std::format("{:%Y-%m-%d %X}", time);
37 }
38
43 String GetDate() const
44 {
45 const auto time = chrono::current_zone()->to_local(m_point);
46 return std::format("{:%Y-%m-%d}", time);
47 }
48
53 String GetTime() const
54 {
55 const auto time = chrono::current_zone()->to_local(m_point);
56 return std::format("{:%X}", time);
57 }
58
63 inline operator TimePoint() const
64 {
65 return m_point;
66 }
67
68 private:
69 TimePoint m_point;
70 };
71}
Timestamp utility class, wraps chrono::system_clock::time_point.
Definition Timestamp.h:10
Timestamp(const TimePoint &point)
Constructor, sets timestamp to specified time.
Definition Timestamp.h:25
String GetDate() const
Get formatted date (Format: "YYYY-MM-DD")
Definition Timestamp.h:43
Timestamp()
Default constructor, sets timestamp to current time.
Definition Timestamp.h:18
String GetDateAndTime() const
Get formatted date and time (Format: "YYYY-MM-DD HH:MM:SS`")
Definition Timestamp.h:33
String GetTime() const
Get formatted time (Format: "HH:MM:SS")
Definition Timestamp.h:53