/usr/include/boost/date_time
NameSizeModeActions
gregorian/-0755rm
local_time/-0755rm
posix_time/-0755rm
adjust_functors.hpp54670644editdlrm
compiler_config.hpp56400644editdlrm
constrained_value.hpp42240644editdlrm
c_local_time_adjustor.hpp26310644editdlrm
c_time.hpp44960644editdlrm
date.hpp73570644editdlrm
date_clock_device.hpp22990644editdlrm
date_defs.hpp7010644editdlrm
date_duration.hpp46690644editdlrm
date_duration_types.hpp91860644editdlrm
date_facet.hpp293140644editdlrm
date_formatting.hpp42080644editdlrm
date_formatting_limited.hpp34610644editdlrm
date_formatting_locales.hpp67480644editdlrm
date_format_simple.hpp31280644editdlrm
date_generators.hpp165080644editdlrm
date_generator_formatter.hpp117150644editdlrm
date_generator_parser.hpp130640644editdlrm
date_iterator.hpp33050644editdlrm
date_names_put.hpp107540644editdlrm
date_parsing.hpp141460644editdlrm
dst_rules.hpp154010644editdlrm
dst_transition_generators.hpp22930644editdlrm
filetime_functions.hpp31630644editdlrm
find_match.hpp13550644editdlrm
format_date_parser.hpp239090644editdlrm
gregorian_calendar.hpp27140644editdlrm
gregorian_calendar.ipp79470644editdlrm
int_adapter.hpp144630644editdlrm
iso_format.hpp56400644editdlrm
locale_config.hpp12060644editdlrm
local_timezone_defs.hpp76180644editdlrm
local_time_adjustor.hpp85780644editdlrm
microsec_time_clock.hpp62570644editdlrm
parse_format_base.hpp9610644editdlrm
period.hpp119360644editdlrm
period_formatter.hpp72370644editdlrm
period_parser.hpp79320644editdlrm
special_defs.hpp6330644editdlrm
special_values_formatter.hpp36570644editdlrm
special_values_parser.hpp61610644editdlrm
strings_from_facet.hpp45050644editdlrm
string_convert.hpp10020644editdlrm
string_parse_tree.hpp84050644editdlrm
time.hpp67880644editdlrm
time_clock.hpp22450644editdlrm
time_defs.hpp9420644editdlrm
time_duration.hpp105690644editdlrm
time_facet.hpp589880644editdlrm
time_formatting_streams.hpp37520644editdlrm
time_iterator.hpp14380644editdlrm
time_parsing.hpp118460644editdlrm
time_resolution_traits.hpp67600644editdlrm
time_system_counted.hpp90510644editdlrm
time_system_split.hpp80770644editdlrm
time_zone_base.hpp37110644editdlrm
time_zone_names.hpp31030644editdlrm
tz_db_base.hpp159150644editdlrm
wrapping_int.hpp58240644editdlrm
year_month_day.hpp13750644editdlrm
Edit: /usr/include/boost/date_time/date.hpp (7357B)
#ifndef DATE_TIME_DATE_HPP___ #define DATE_TIME_DATE_HPP___ /* Copyright (c) 2002,2003 CrystalClear Software, Inc. * Use, modification and distribution is subject to the * Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) * Author: Jeff Garland, Bart Garst * $Date$ */ #include #include #include #include namespace boost { namespace date_time { //!Representation of timepoint at the one day level resolution. /*! The date template represents an interface shell for a date class that is based on a year-month-day system such as the gregorian or iso systems. It provides basic operations to enable calculation and comparisons. Theory This date representation fundamentally departs from the C tm struct approach. The goal for this type is to provide efficient date operations (add, subtract) and storage (minimize space to represent) in a concrete class. Thus, the date uses a count internally to represent a particular date. The calendar parameter defines the policies for converting the the year-month-day and internal counted form here. Applications that need to perform heavy formatting of the same date repeatedly will perform better by using the year-month-day representation. Internally the date uses a day number to represent the date. This is a monotonic time representation. This representation allows for fast comparison as well as simplifying the creation of writing numeric operations. Essentially, the internal day number is like adjusted julian day. The adjustment is determined by the Epoch date which is represented as day 1 of the calendar. Day 0 is reserved for negative infinity so that any actual date is automatically greater than negative infinity. When a date is constructed from a date or formatted for output, the appropriate conversions are applied to create the year, month, day representations. */ template class BOOST_SYMBOL_VISIBLE date : private boost::less_than_comparable > { public: typedef T date_type; typedef calendar calendar_type; typedef typename calendar::date_traits_type traits_type; typedef duration_type_ duration_type; typedef typename calendar::year_type year_type; typedef typename calendar::month_type month_type; typedef typename calendar::day_type day_type; typedef typename calendar::ymd_type ymd_type; typedef typename calendar::date_rep_type date_rep_type; typedef typename calendar::date_int_type date_int_type; typedef typename calendar::day_of_week_type day_of_week_type; BOOST_CXX14_CONSTEXPR date(year_type y, month_type m, day_type d) : days_(calendar::day_number(ymd_type(y, m, d))) {} BOOST_CXX14_CONSTEXPR date(const ymd_type& ymd) : days_(calendar::day_number(ymd)) {} //let the compiler write copy, assignment, and destructor BOOST_CXX14_CONSTEXPR year_type year() const { ymd_type ymd = calendar::from_day_number(days_); return ymd.year; } BOOST_CXX14_CONSTEXPR month_type month() const { ymd_type ymd = calendar::from_day_number(days_); return ymd.month; } BOOST_CXX14_CONSTEXPR day_type day() const { ymd_type ymd = calendar::from_day_number(days_); return ymd.day; } BOOST_CXX14_CONSTEXPR day_of_week_type day_of_week() const { ymd_type ymd = calendar::from_day_number(days_); return calendar::day_of_week(ymd); } BOOST_CXX14_CONSTEXPR ymd_type year_month_day() const { return calendar::from_day_number(days_); } BOOST_CONSTEXPR bool operator<(const date_type& rhs) const { return days_ < rhs.days_; } BOOST_CONSTEXPR bool operator==(const date_type& rhs) const { return days_ == rhs.days_; } //! check to see if date is a special value BOOST_CONSTEXPR bool is_special()const { return(is_not_a_date() || is_infinity()); } //! check to see if date is not a value BOOST_CONSTEXPR bool is_not_a_date() const { return traits_type::is_not_a_number(days_); } //! check to see if date is one of the infinity values BOOST_CONSTEXPR bool is_infinity() const { return traits_type::is_inf(days_); } //! check to see if date is greater than all possible dates BOOST_CONSTEXPR bool is_pos_infinity() const { return traits_type::is_pos_inf(days_); } //! check to see if date is greater than all possible dates BOOST_CONSTEXPR bool is_neg_infinity() const { return traits_type::is_neg_inf(days_); } //! return as a special value or a not_special if a normal date BOOST_CXX14_CONSTEXPR special_values as_special() const { return traits_type::to_special(days_); } BOOST_CXX14_CONSTEXPR duration_type operator-(const date_type& d) const { if (!this->is_special() && !d.is_special()) { // The duration underlying type may be wider than the date underlying type. // Thus we calculate the difference in terms of two durations from some common fixed base date. typedef typename duration_type::duration_rep_type duration_rep_type; return duration_type(static_cast< duration_rep_type >(days_) - static_cast< duration_rep_type >(d.days_)); } else { // In this case the difference will be a special value, too date_rep_type val = date_rep_type(days_) - date_rep_type(d.days_); return duration_type(val.as_special()); } } BOOST_CXX14_CONSTEXPR date_type operator-(const duration_type& dd) const { if(dd.is_special()) { return date_type(date_rep_type(days_) - dd.get_rep()); } return date_type(date_rep_type(days_) - static_cast(dd.days())); } BOOST_CXX14_CONSTEXPR date_type operator-=(const duration_type& dd) { *this = *this - dd; return date_type(days_); } BOOST_CONSTEXPR date_rep_type day_count() const { return days_; } //allow internal access from operators BOOST_CXX14_CONSTEXPR date_type operator+(const duration_type& dd) const { if(dd.is_special()) { return date_type(date_rep_type(days_) + dd.get_rep()); } return date_type(date_rep_type(days_) + static_cast(dd.days())); } BOOST_CXX14_CONSTEXPR date_type operator+=(const duration_type& dd) { *this = *this + dd; return date_type(days_); } //see reference protected: /*! This is a private constructor which allows for the creation of new dates. It is not exposed to users since that would require class users to understand the inner workings of the date class. */ BOOST_CONSTEXPR explicit date(date_int_type days) : days_(days) {} BOOST_CXX14_CONSTEXPR explicit date(date_rep_type days) : days_(days.as_number()) {} date_int_type days_; }; } } // namespace date_time #endif