Switched the file added info back to a full date time, ref #601

This commit is contained in:
emeric
2025-01-26 15:08:31 +01:00
parent e553e840d3
commit 814eaf0a3e
12 changed files with 96 additions and 55 deletions
+16 -11
View File
@@ -43,11 +43,26 @@ namespace lms::core
static PartialDateTime fromWtDateTime(const Wt::WDateTime& dateTime);
std::string toISO8601String() const;
bool isValid() const { return _precision != Precision::Invalid; }
constexpr bool isValid() const { return _precision != Precision::Invalid; }
enum class Precision : std::uint8_t
{
Invalid,
Year,
Month,
Day,
Hour,
Min,
Sec,
};
constexpr Precision getPrecision() const { return _precision; }
constexpr std::optional<int> getYear() const { return (_precision >= Precision::Year ? std::make_optional(_year) : std::nullopt); }
constexpr std::optional<int> getMonth() const { return (_precision >= Precision::Month ? std::make_optional(_month) : std::nullopt); }
constexpr std::optional<int> getDay() const { return (_precision >= Precision::Day ? std::make_optional(_day) : std::nullopt); }
constexpr std::optional<int> getHour() const { return (_precision >= Precision::Hour ? std::make_optional(_hour) : std::nullopt); }
constexpr std::optional<int> getMin() const { return (_precision >= Precision::Min ? std::make_optional(_min) : std::nullopt); }
constexpr std::optional<int> getSec() const { return (_precision >= Precision::Sec ? std::make_optional(_sec) : std::nullopt); }
constexpr auto operator<=>(const PartialDateTime& other) const = default;
@@ -60,16 +75,6 @@ namespace lms::core
std::uint8_t _hour{}; // 0 to 23
std::uint8_t _min{}; // 0 to 59
std::uint8_t _sec{}; // 0 to 59
enum class Precision : std::uint8_t
{
Invalid,
Year,
Month,
Day,
Hour,
Min,
Sec,
};
Precision _precision{ Precision::Invalid };
};
} // namespace lms::core