25#ifndef __GNC_DATETIME_HPP__
26#define __GNC_DATETIME_HPP__
35#include <boost/date_time/gregorian/gregorian.hpp>
36#include <boost/regex.hpp>
55constexpr const time64 MINTIME = -17987443200;
56constexpr const time64 MAXTIME = 253402214400;
120 explicit operator time64()
const;
123 explicit operator struct tm()
const;
138 bool isnull (
void) {
return m_impl ==
nullptr; }
167 std::unique_ptr<GncDateTimeImpl> m_impl;
180using StringToDate = std::function<boost::gregorian::date(
const std::string&)>;
191 m_fmt(fmt), m_re(re) {}
192 GncDateFormat (
const char* fmt, StringToDate str_to_date,
const char* re) :
193 m_fmt(fmt), m_re(re), m_str_to_date(str_to_date) {}
195 m_fmt(fmt), m_str_to_date(str_to_date) {}
203 std::optional<StringToDate> m_str_to_date;
250 GncDate(
int year,
int month,
int day);
267 GncDate(
const std::string str,
const std::string fmt);
270 GncDate(std::unique_ptr<GncDateImpl> impl);
302 bool isnull (
void) {
return m_impl ==
nullptr; }
305 std::unique_ptr<GncDateImpl> m_impl;
Private implementation of GncDate.
std::string format_iso8601() const
Format the GncDateTime into a gnucash-style iso8601 string in UTC.
void now()
Set the GncDateTime to the date and time indicated in the computer's clock.
bool isnull(void)
Test if the GncDateTime has a member pointer.
struct tm utc_tm() const
Obtain a struct tm representing the time in UTC.
std::string format_zulu(const char *format) const
Format the GncDateTime into a std::string in GMT.
GncDate date() const
Obtain the date from the time, as a GncDate, in the current timezone.
std::string format(const char *format) const
Format the GncDateTime into a std::string.
static std::string timestamp()
Get an undelimited string representing the current date and time.
GncDateTime()
Construct a GncDateTime representing the current time in the current timezone.
long offset() const
Obtain the UTC offset in seconds.
std::string format(const char *format)
Format the GncDate into a std::string.
friend bool operator<(const GncDate &, const GncDate &)
static const std::vector< GncDateFormat > c_formats
A vector with all the date formats supported by the string constructor.
bool isnull(void)
Test that the Date has an implementation.
GncDate(GncDate &&)
Move constructor.
void today()
Set the date object to the computer clock's current day.
GncDate & operator=(GncDate &&)
Move assignment operator.
~GncDate()
Default destructor.
GncDate()
Construct a GncDate representing the current day.
gnc_ymd year_month_day() const
Get the year, month, and day from the date as a gnc_ymd.
GncDate & operator=(const GncDate &)
Copy assignment operator.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...