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