11#ifndef OPENXLSX_XLDATETIME_HPP
12#define OPENXLSX_XLDATETIME_HPP
16# pragma warning(disable : 4251)
17# pragma warning(disable : 4275)
26#include "OpenXLSX-Exports.hpp"
67 explicit XLDateTime(
const std::chrono::system_clock::time_point& timepoint);
88 [[nodiscard]]
static XLDateTime fromString(
const std::string& dateString,
const std::string& format =
"%Y-%m-%d %H:%M:%S");
94 [[nodiscard]] std::string
toString(
const std::string& format =
"%Y-%m-%d %H:%M:%S")
const;
110 template<
typename T,
typename = std::enable_if_t<std::is_
floating_po
int_v<T>>>
112 {
return static_cast<T
>(
serial()); }
117 operator std::tm()
const;
122 [[nodiscard]] std::chrono::system_clock::time_point chrono()
const;
127 [[nodiscard]]
double serial()
const;
134 [[nodiscard]] std::tm tm()
const;
137 double m_serial{1.0};
static XLDateTime now()
Definition XLDateTime.cpp:103
XLDateTime(const XLDateTime &other)=default
XLDateTime(XLDateTime &&other) noexcept=default
XLDateTime()
Constructs an object representing the Excel epoch (1900-01-01).
XLDateTime & operator=(XLDateTime &&other) noexcept=default
std::string toString(const std::string &format="%Y-%m-%d %H:%M:%S") const
Formats the date into a human-readable string.
Definition XLDateTime.cpp:114
static XLDateTime fromString(const std::string &dateString, const std::string &format="%Y-%m-%d %H:%M:%S")
Parses a string into an Excel date.
Definition XLDateTime.cpp:105
XLDateTime & operator=(const XLDateTime &other)=default
double serial() const
Definition XLDateTime.cpp:143
Definition IXLCellProvider.hpp:24