| Home | Libraries | People | FAQ | More

## Class template dst_calculator

boost::date_time::dst_calculator — Dynamic class used to caluclate dst transition information.

## Synopsis

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

    template<typename date_type_, typename time_duration_type_>
    class dst_calculator {
    public:
      // types
      typedef time_duration_type_ time_duration_type;
      typedef date_type_          date_type;

      // public static functions
      static time_is_dst_result
      process_local_dst_start_day(const time_duration_type &, unsigned int, long);
      static time_is_dst_result
      process_local_dst_end_day(const time_duration_type &, unsigned int, long);
      static time_is_dst_result
      local_is_dst(const date_type &, const time_duration_type &,
                   const date_type &, const time_duration_type &,
                   const date_type &, const time_duration_type &,
                   const time_duration_type &);
      static time_is_dst_result
      local_is_dst(const date_type &, const time_duration_type &,
                   const date_type &, unsigned int, const date_type &,
                   unsigned int, long);
    };

## Description

### `dst_calculator` public static functions

1.     static time_is_dst_result
       process_local_dst_start_day(const time_duration_type & time_of_day,
                                   unsigned int dst_start_offset_minutes,
                                   long dst_length_minutes);

   Check the local time offset when on dst start day.

   On this dst transition, the time label between the transition boundary and the boudary + the offset are invalid times. If before the boundary then still not in dst.

   Parameters: |

   `dst_length_minutes` | Number of minutes to adjust clock forward
   `dst_start_offset_minutes` | Local day offset for start of dst
   `time_of_day` | Time offset in the day for the local time

2.     static time_is_dst_result
       process_local_dst_end_day(const time_duration_type & time_of_day,
                                 unsigned int dst_end_offset_minutes,
                                 long dst_length_minutes);

   Check the local time offset when on the last day of dst.

   This is the calculation for the DST end day. On that day times prior to the conversion time - dst_length (1 am in US) are still in dst. Times between the above and the switch time are ambiguous. Times after the start_offset are not in dst.

   Parameters: |

   `dst_end_offset_minutes` | Local time of day for end of dst
   `time_of_day` | Time offset in the day for the local time

3.     static time_is_dst_result
       local_is_dst(const date_type & current_day,
                    const time_duration_type & time_of_day,
                    const date_type & dst_start_day,
                    const time_duration_type & dst_start_offset,
                    const date_type & dst_end_day,
                    const time_duration_type & dst_end_offset,
                    const time_duration_type & dst_length_minutes);

   Calculates if the given local time is dst or not.

   Determines if the time is really in DST or not. Also checks for invalid and ambiguous.

   Parameters: |

   `current_day` | The day to check for dst
   `dst_end_day` | Ending day of dst for the given locality
   `dst_end_offset` | Time offset within day given in dst for dst boundary
   `dst_start_day` | Starting day of dst for the given locality
   `dst_start_offset` | Time offset within day for dst boundary
   `time_of_day` | Time offset within the day to check

4.     static time_is_dst_result
       local_is_dst(const date_type & current_day,
                    const time_duration_type & time_of_day,
                    const date_type & dst_start_day,
                    unsigned int dst_start_offset_minutes,
                    const date_type & dst_end_day,
                    unsigned int dst_end_offset_minutes, long dst_length_minutes);

   Calculates if the given local time is dst or not.

   Determines if the time is really in DST or not. Also checks for invalid and ambiguous.

   Parameters: |

   `current_day` | The day to check for dst
   `dst_end_day` | Ending day of dst for the given locality
   `dst_end_offset_minutes` | Offset within day given in dst for dst boundary (eg 120 for US which is 02:00:00)
   `dst_length_minutes` | Length of dst adjusment (eg: 60 for US)
   `dst_start_day` | Starting day of dst for the given locality
   `dst_start_offset_minutes` | Offset within day for dst boundary (eg 120 for US which is 02:00:00)
   `time_of_day` | Time offset within the day to check