34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
/*
|
|
* File: Timestamp.h
|
|
* Description: Provides a utility class for representing and manipulating time values.
|
|
* Supports conversion between string and time formats, duration calculations
|
|
* (hours, minutes, seconds), date extraction, and comparison operators.
|
|
* Author: Trenser
|
|
* Created: 18-May-2026
|
|
*/
|
|
|
|
#pragma once
|
|
#include <ctime>
|
|
#include <string>
|
|
|
|
namespace util
|
|
{
|
|
class Timestamp
|
|
{
|
|
private:
|
|
std::time_t m_time;
|
|
Timestamp(std::time_t time);
|
|
public:
|
|
Timestamp();
|
|
static Timestamp fromString(const std::string& timeString);
|
|
std::string toString() const;
|
|
static double getDurationInHours(const Timestamp&, const Timestamp&);
|
|
static double getDurationInMinutes(const Timestamp&, const Timestamp&);
|
|
static double getDurationInSeconds(const Timestamp&, const Timestamp&);
|
|
bool operator>(const Timestamp&) const;
|
|
bool operator<(const Timestamp&) const;
|
|
bool operator>=(const Timestamp&) const;
|
|
bool operator<=(const Timestamp&) const;
|
|
bool operator==(const Timestamp&) const;
|
|
};
|
|
} |