boost.png (6897 bytes) Home Libraries People FAQ More

PrevUpHomeNext

Class template base_time

boost::date_time::base_time — Representation of a precise moment in time, including the date.

Synopsis

template<typename T, typename time_system> 
class base_time {
public:
  // types
  typedef T                               time_type;         
  typedef time_system::time_rep_type      time_rep_type;     
  typedef time_system::date_type          date_type;         
  typedef time_system::date_duration_type date_duration_type;
  typedef time_system::time_duration_type time_duration_type;

  // construct/copy/destruct
  base_time(const date_type &, const time_duration_type &, 
            dst_flags = not_dst);
  base_time(special_values);
  base_time(const time_rep_type &);

  // public member functions
  date_type date() const;
  time_duration_type time_of_day() const;
  std::string zone_name(bool = false) const;
  std::string zone_abbrev(bool = false) const;
  std::string zone_as_posix_string() const;
  bool is_not_a_date_time() const;
  bool is_infinity() const;
  bool is_pos_infinity() const;
  bool is_neg_infinity() const;
  bool is_special() const;
  bool operator==(const time_type &) const;
  bool operator<(const time_type &) const;
  time_duration_type operator-(const time_type &) const;
  time_type operator+(const date_duration_type &) const;
  time_type operator+=(const date_duration_type &) ;
  time_type operator-(const date_duration_type &) const;
  time_type operator-=(const date_duration_type &) ;
  time_type operator+(const time_duration_type &) const;
  time_type operator+=(const time_duration_type &) ;
  time_type operator-(const time_duration_type &) const;
  time_type operator-=(const time_duration_type &) ;
};

Description

This class is a skeleton for the interface of a temporal type with a resolution that is higher than a day. It is intended that this class be the base class and that the actual time class be derived using the BN pattern. In this way, the derived class can make decisions such as 'should there be a default constructor' and what should it set its value to, should there be optional constructors say allowing only an time_durations that generate a time from a clock,etc. So, in fact multiple time types can be created for a time_system with different construction policies, and all of them can perform basic operations by only writing a copy constructor. Finally, compiler errors are also shorter.

The real behavior of the time class is provided by the time_system template parameter. This class must provide all the logic for addition, subtraction, as well as define all the interface types.

base_time construct/copy/destruct

  1. base_time(const date_type & day, const time_duration_type & td, 
              dst_flags dst = not_dst);
  2. base_time(special_values sv);
  3. base_time(const time_rep_type & rhs);

base_time public member functions

  1. date_type date() const;
  2. time_duration_type time_of_day() const;
  3. std::string zone_name(bool as_offset = false) const;

    Optional bool parameter will return time zone as an offset (ie "+07:00"). Empty string is returned for classes that do not use a time_zone

  4. std::string zone_abbrev(bool as_offset = false) const;

    Optional bool parameter will return time zone as an offset (ie "+07:00"). Empty string is returned for classes that do not use a time_zone

  5. std::string zone_as_posix_string() const;
  6. bool is_not_a_date_time() const;
  7. bool is_infinity() const;
  8. bool is_pos_infinity() const;
  9. bool is_neg_infinity() const;
  10. bool is_special() const;
  11. bool operator==(const time_type & rhs) const;
  12. bool operator<(const time_type & rhs) const;
  13. time_duration_type operator-(const time_type & rhs) const;
  14. time_type operator+(const date_duration_type & dd) const;
  15. time_type operator+=(const date_duration_type & dd) ;
  16. time_type operator-(const date_duration_type & dd) const;
  17. time_type operator-=(const date_duration_type & dd) ;
  18. time_type operator+(const time_duration_type & td) const;
  19. time_type operator+=(const time_duration_type & td) ;
  20. time_type operator-(const time_duration_type & rhs) const;
  21. time_type operator-=(const time_duration_type & td) ;
Copyright © 2001-2005 CrystalClear Software, Inc

PrevUpHomeNext