Boost C++ Libraries

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

Click here to view the latest version of this page.
PrevUpHomeNext

Class template local_adjustor

boost::date_time::local_adjustor — Template that simplifies the creation of local time calculator.

Synopsis

template<typename time_type, short utc_offset, typename dst_rule> 
class local_adjustor {
public:
  // types
  typedef time_type::time_duration_type                                                                       time_duration_type;
  typedef time_type::date_type                                                                                date_type;         
  typedef static_local_time_adjustor< time_type, dst_rule, utc_adjustment< time_duration_type, utc_offset > > dst_adjustor;      

  // public static functions
  static time_type utc_to_local(const time_type &) ;
  static time_type 
  local_to_utc(const time_type &, date_time::dst_flags = date_time::calculate) ;
};

Description

Use this template to create the timezone to utc convertors as required.

This class will also work for other regions that don't use dst and have a utc offset which is an integral number of hours.

Template Parameters -time_type -- Time class to use -utc_offset -- Number hours local time is adjust from utc -use_dst -- true (default) if region uses dst, false otherwise For example:

  //eastern timezone is utc-5
     typedef date_time::local_adjustor<ptime, -5, us_dst> us_eastern;
     typedef date_time::local_adjustor<ptime, -6, us_dst> us_central;
     typedef date_time::local_adjustor<ptime, -7, us_dst> us_mountain;
     typedef date_time::local_adjustor<ptime, -8, us_dst> us_pacific;
     typedef date_time::local_adjustor<ptime, -7, no_dst> us_arizona;

local_adjustor public static functions

  1. static time_type utc_to_local(const time_type & t) ;
  2. static time_type 
    local_to_utc(const time_type & t, 
                 date_time::dst_flags dst = date_time::calculate) ;
Copyright © 2001-2005 CrystalClear Software, Inc

PrevUpHomeNext