| Home | Libraries | People | FAQ | More

## Class template static_local_time_adjustor

boost::date_time::static_local_time_adjustor — Embed the rules for local time adjustments at compile time.

## Synopsis

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

    template<typename time_type, typename dst_rules, typename utc_offset_rules>
    class static_local_time_adjustor {
    public:
      // types
      typedef time_type::time_duration_type time_duration_type;
      typedef time_type::date_type          date_type;

      // public static functions
      static time_duration_type utc_to_local_offset(const time_type &) ;
      static time_duration_type
      local_to_utc_offset(const time_type &,
                          date_time::dst_flags = date_time::calculate) ;
    };

## Description

### `static_local_time_adjustor` public static functions

1.     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.

   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.

   Parameters: |
   `t` | UTC 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.

2.     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.