57 return !
moment.is_not_a_date_time();
60typedef boost::gregorian::date
date_t;
64 return !
moment.is_not_a_date();
69#ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
70#define TRUE_CURRENT_TIME() (boost::posix_time::microsec_clock::local_time())
71#define CURRENT_TIME() (epoch ? *epoch : TRUE_CURRENT_TIME())
73#define TRUE_CURRENT_TIME() (boost::posix_time::second_clock::local_time())
74#define CURRENT_TIME() (epoch ? *epoch : TRUE_CURRENT_TIME())
76#define CURRENT_DATE() \
77 (epoch ? epoch->date() : boost::gregorian::day_clock::local_day())
192#if !defined(__clang__)
210#if !defined(__clang__)
216 std::ostringstream out;
221 case DAYS: out <<
"day";
break;
222 case WEEKS: out <<
"week";
break;
223 case MONTHS: out <<
"month";
break;
224 case QUARTERS: out <<
"quarter";
break;
225 case YEARS: out <<
"year";
break;
264 "year_type, month_type, day_type, day_of_week_type");
305 std::ostringstream out;
308 out <<
" year " << *
year;
310 out <<
" month " << *
month;
312 out <<
" day " << *
day;
314 out <<
" wday " << *
wday;
333 end_inclusive(
false) {
337 : range_begin(
other.range_begin), range_end(
other.range_end),
338 end_inclusive(
other.end_inclusive) {
347 return range_begin->begin();
354 return range_end->end();
356 return range_end->begin();
371 std::ostringstream out;
374 out <<
"from" << range_begin->to_string();
376 out <<
" to" << range_end->to_string();
386 value_type specifier_or_range;
393 : specifier_or_range(
other.specifier_or_range) {
401 : specifier_or_range(range) {
410 return boost::get<date_specifier_t>(specifier_or_range).begin();
411 else if (specifier_or_range.type() ==
typeid(
date_range_t))
412 return boost::get<date_range_t>(specifier_or_range).begin();
418 return boost::get<date_specifier_t>(specifier_or_range).end();
419 else if (specifier_or_range.type() ==
typeid(
date_range_t))
420 return boost::get<date_range_t>(specifier_or_range).end();
427 std::ostringstream out;
430 out <<
"in" << boost::get<date_specifier_t>(specifier_or_range).to_string();
431 else if (specifier_or_range.type() ==
typeid(
date_range_t))
504 return static_cast<bool>(
start);
511 const bool align_intervals =
false,
General utility facilities used by Ledger.
#define TRACE_CTOR(cls, args)
#define DECLARE_EXCEPTION(name, kind)
optional< date_time::months_of_year > string_to_month_of_year(const std::string &str)
void put_date(property_tree::ptree &pt, const date_t &when)
std::string format_datetime(const datetime_t &when, const format_type_t format_type=FMT_PRINTED, const optional< const char * > &format=none)
void set_date_format(const char *format)
optional< datetime_t > epoch
datetime_t::time_duration_type time_duration_t
bool is_valid(const datetime_t &moment)
void set_input_date_format(const char *format)
boost::gregorian::date date_t
boost::gregorian::date_iterator date_iterator_t
void put_datetime(property_tree::ptree &pt, const datetime_t &when)
std::string format_date(const date_t &when, const format_type_t format_type=FMT_PRINTED, const optional< const char * > &format=none)
date_time::weekdays start_of_week
std::ostream & operator<<(std::ostream &out, const account_t &account)
void show_period_tokens(std::ostream &out, const string &arg)
optional< date_time::weekdays > string_to_day_of_week(const std::string &str)
void set_datetime_format(const char *format)
datetime_t parse_datetime(const char *str)
boost::posix_time::ptime datetime_t
date_t parse_date(const char *str)
bool operator==(const date_traits_t &traits) const
date_traits_t(const date_traits_t &traits)
date_traits_t & operator=(const date_traits_t &traits)
date_traits_t(bool _has_year=false, bool _has_month=false, bool _has_day=false)
date_t add(const date_t &date) const
static date_t find_nearest(const date_t &date, skip_quantum_t skip)
enum ledger::date_duration_t::skip_quantum_t quantum
date_t subtract(const date_t &date) const
date_duration_t(const date_duration_t &dur)
date_duration_t(skip_quantum_t _quantum, int _length)
date_specifier_t(const optional< year_type > &_year=none, const optional< month_type > &_month=none, const optional< day_type > &_day=none, const optional< day_of_week_type > &_wday=none)
optional< month_type > month
optional< day_of_week_type > wday
bool is_within(const date_t &date) const
optional< date_duration_t > implied_duration() const
optional< year_type > year
date_t::day_type day_type
date_t::month_type month_type
date_t::day_of_week_type day_of_week_type
friend class date_parser_t
date_specifier_t(const date_specifier_t &other)
date_specifier_t(const date_t &date, const optional< date_traits_t > &traits=none)
date_range_t(const optional< date_specifier_t > &_range_begin=none, const optional< date_specifier_t > &_range_end=none)
optional< date_t > end() const
optional< date_t > begin() const
bool is_within(const date_t &date) const
date_range_t(const date_range_t &other)
friend class date_parser_t
optional< date_t > end() const
~date_specifier_or_range_t()
date_specifier_or_range_t()
date_specifier_or_range_t(const date_range_t &range)
optional< date_t > begin() const
date_specifier_or_range_t(const date_specifier_t &specifier)
date_specifier_or_range_t(const date_specifier_or_range_t &other)
optional< date_t > begin() const
void dump(std::ostream &out)
optional< date_t > finish
void stabilize(const optional< date_t > &date=none, bool align_intervals=false)
static date_t subtract_duration(const date_t &date, const date_duration_t &duration)
date_interval_t & operator++()
bool operator<(const date_interval_t &other) const
optional< date_t > end() const
optional< date_t > end_of_duration
date_interval_t(const string &str)
void parse(const string &str)
static date_t add_duration(const date_t &date, const date_duration_t &duration)
bool operator==(const date_interval_t &other) const
date_interval_t(const date_interval_t &other)
optional< date_t > inclusive_end() const
bool within_period(const date_t &date=(epoch ? epoch->date() :boost::gregorian::day_clock::local_day()))
optional< date_specifier_or_range_t > range
bool find_period(const date_t &date=(epoch ? epoch->date() :boost::gregorian::day_clock::local_day()), const bool align_intervals=false, const bool allow_shift=true)
Find the current or next period containing date.
optional< date_duration_t > duration