Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::date_time::static_local_time_adjustor< time_type, dst_rules, utc_offset_rules > Class Template Reference

Embed the rules for local time adjustments at compile time. More...

#include <local_time_adjustor.hpp>

Inheritance diagram for boost::date_time::static_local_time_adjustor< time_type, dst_rules, utc_offset_rules >:
Collaboration diagram for boost::date_time::static_local_time_adjustor< time_type, dst_rules, utc_offset_rules >:

Public Types

typedef
time_type::time_duration_type 
time_duration_type
 
typedef time_type::date_type date_type
 

Static Public Member Functions

static time_duration_type utc_to_local_offset (const time_type &t)
 Calculates the offset from a utc time to local based on dst and utc offset. More...
 
static time_duration_type local_to_utc_offset (const time_type &t, date_time::dst_flags dst=date_time::calculate)
 Get the offset to UTC given a local time. More...
 

Detailed Description

template<class time_type, class dst_rules, class utc_offset_rules>
class boost::date_time::static_local_time_adjustor< time_type, dst_rules, utc_offset_rules >

Embed the rules for local time adjustments at compile time.

Member Typedef Documentation

template<class time_type , class dst_rules , class utc_offset_rules >
typedef time_type::date_type boost::date_time::static_local_time_adjustor< time_type, dst_rules, utc_offset_rules >::date_type
template<class time_type , class dst_rules , class utc_offset_rules >
typedef time_type::time_duration_type boost::date_time::static_local_time_adjustor< time_type, dst_rules, utc_offset_rules >::time_duration_type

Member Function Documentation

template<class time_type , class dst_rules , class utc_offset_rules >
static time_duration_type boost::date_time::static_local_time_adjustor< time_type, dst_rules, utc_offset_rules >::utc_to_local_offset ( const time_type &  t)
inlinestatic

Calculates the offset from a utc time to local based on dst and utc offset.

Parameters
tUTC time to calculate offset to local time This adjustment depends on the following observations about the workings of the DST boundary offset. Since UTC time labels are monotonically increasing we can determine if a given local time is in DST or not and therefore adjust the offset appropriately.

The logic is as follows. Starting with UTC time use the offset to create a label for an non-dst adjusted local time. Then call dst_rules::local_is_dst with the non adjust local time. The results of this function will either unabiguously decide that the initial local time is in dst or return an illegal or ambiguous result. An illegal result only occurs at the end of dst (where labels are skipped) and indicates that dst has ended. An ambiguous result means that we need to recheck by making a dst adjustment and then rechecking. If the dst offset is added to the utc time and the recheck proves non-ambiguous then we are past the boundary. If it is still ambiguous then we are ahead of the boundary and dst is still in effect.

TODO – check if all dst offsets are positive. If not then the algorithm needs to check for this and reverse the illegal/ambiguous logic.

References boost::date_time::ambiguous, BOOST_DATE_TIME_UNREACHABLE_EXPRESSION, boost::date_time::invalid_time_label, boost::date_time::is_in_dst, boost::date_time::is_not_in_dst, boost::date_time::not_a_date_time, and boost::throw_exception().

Referenced by boost::date_time::local_adjustor< time_type, utc_offset, dst_rule >::utc_to_local().


The documentation for this class was generated from the following file: