Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Class template day_clock

boost::date_time::day_clock — A clock providing day level services based on C time_t capabilities.


// In header: <boost/date_time/date_clock_device.hpp>

template<typename date_type> 
class day_clock {
  // types
  typedef date_type::ymd_type ymd_type;

  // public static functions
  static date_type local_day();
  static date_type::ymd_type local_day_ymd();
  static date_type::ymd_type universal_day_ymd();
  static date_type universal_day();

  // private static functions
  static ::std::tm * get_local_time(std::tm &);
  static ::std::tm * get_universal_time(std::tm &);


This clock uses Posix interfaces as its implementation and hence uses the timezone settings of the operating system. Incorrect user settings will result in incorrect results for the calls to local_day.

day_clock public static functions

  1. static date_type local_day();
    Get the local day as a date type.
  2. static date_type::ymd_type local_day_ymd();
    Get the local day as a ymd_type.
  3. static date_type::ymd_type universal_day_ymd();
    Get the current day in universal date as a ymd_type.
  4. static date_type universal_day();
    Get the UTC day as a date type.

day_clock private static functions

  1. static ::std::tm * get_local_time(std::tm & result);
  2. static ::std::tm * get_universal_time(std::tm & result);