SA_Logger
Sapphire's Suite's C++ Logger.
Loading...
Searching...
No Matches
DateTime.hpp
Go to the documentation of this file.
1// Copyright (c) 2023 Sapphire's Suite. All Rights Reserved.
2
3#pragma once
4
5#ifndef SAPPHIRE_LOGGER_DATE_TIME_GUARD
6#define SAPPHIRE_LOGGER_DATE_TIME_GUARD
7
8#include <cstdint>
9
10#include <string>
11
22namespace SA
23{
25 struct DateTime
26 {
28 uint8_t second = 0;
29
31 uint8_t minute = 0;
32
34 uint8_t hour = 0;
35
37 uint8_t day = 0;
38
40 uint8_t month = 0;
41
43 uint16_t year = 0;
44
46 uint8_t weekday = 0;
47
48
49//{ Constructors
50
52 DateTime() = default;
53
65 DateTime(uint8_t _second,
66 uint8_t _minute = 0u,
67 uint8_t _hour = 0u,
68 uint8_t _day = 0u,
69 uint8_t _month = 0u,
70 uint16_t _year = 0u,
71 uint8_t _weekday = 0u
72 ) noexcept;
73
79 DateTime(const struct tm& _time) noexcept;
80
81//}
82
83//{ Equals
84
92 bool Equals(const DateTime& _other) const noexcept;
93
101 bool operator==(const DateTime& _rhs) const noexcept;
102
110 bool operator!=(const DateTime& _rhs) const noexcept;
111
112//}
113
119 static DateTime Now() noexcept;
120
126 static DateTime GMNow() noexcept;
127
128
136 static DateTime FileStats(const std::string& _path);
137 };
138
139
148 std::string ToString(const DateTime& _date);
149}
150
151
154#endif // GUARD
Date time structure type.
Definition DateTime.hpp:26
static DateTime FileStats(const std::string &_path)
Query file date time stats at path.
uint8_t hour
hour number [0, 23].
Definition DateTime.hpp:34
uint8_t second
second number [0, 59].
Definition DateTime.hpp:28
uint8_t day
day of the month number [1, 31].
Definition DateTime.hpp:37
uint8_t minute
minute number [0, 59].
Definition DateTime.hpp:31
bool operator!=(const DateTime &_rhs) const noexcept
Compare two DateTime inequality.
uint8_t month
month number [1, 12].
Definition DateTime.hpp:40
DateTime(uint8_t _second, uint8_t _minute=0u, uint8_t _hour=0u, uint8_t _day=0u, uint8_t _month=0u, uint16_t _year=0u, uint8_t _weekday=0u) noexcept
uint16_t year
Year number.
Definition DateTime.hpp:43
DateTime(const struct tm &_time) noexcept
static DateTime GMNow() noexcept
Get the current date time at Greenwich.
static DateTime Now() noexcept
Get the current local date time.
bool Equals(const DateTime &_other) const noexcept
Compare two DateTime equality.
uint8_t weekday
day number of the week [0, 6].
Definition DateTime.hpp:46
DateTime()=default
Default constructor.
bool operator==(const DateTime &_rhs) const noexcept
Compare two DateTime equality.