Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6371413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:03:57+00:00 2026-05-25T01:03:57+00:00

I want to convert a boost::posix_time::ptime to a boost::local_time::local_date_time using a timezone without daylight

  • 0

I want to convert a boost::posix_time::ptime to a boost::local_time::local_date_time using a timezone without daylight saving time only specified by it’s offset to UTC. I am using boost 1.47.0.

Currently I’m trying to create a boost::local_time::custom_time_zone (a.k.a custom_time_zone_base<char>). The only constructor of that class template is the follows:

custom_time_zone_base(
    const time_zone_names& zone_names,   
    const time_duration_type& utc_offset,
    const dst_adjustment_offsets& dst_shift,
    boost::shared_ptr<dst_calc_rule> calc_rule);

What should I supply as the dst_shift and calc_rule arguments? Or is there another class that better suits my needs, as I’m also supplying a zone_names as a boost::local_time::time_zone_names initialized with 4 empty strings.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:03:57+00:00Added an answer on May 25, 2026 at 1:03 am

    The example in the date time docs shows you how to create a custom time zone without DST. You can see it at http://www.boost.org/doc/libs/1_47_0/doc/html/date_time/examples.html#date_time.examples.simple_time_zone.

    Look at the code for the phx_1 timezone. You basically pass in a dst_adjustment_offsets initialized to three copies of time_duration(0,0,0) (3rd parameter) and pass in an empty shared pointer for the calculation rules (4th parameter).

    (From the examples:)

    // create more dependent objects for a non-dst custom_time_zone
    time_zone_names tzn2("Mountain Standard Time", "MST", "", ""); // no dst means empty dst strings
    time_duration utc_offset2(-7,0,0);
    dst_adjustment_offsets adj_offsets2(time_duration(0,0,0), 
                                        time_duration(0,0,0), 
                                        time_duration(0,0,0));
    // no dst means we need a null pointer to the rules
    shared_ptr<dst_calc_rule> phx_rules;
    
    // create the custom_time_zones
    time_zone_ptr phx_1(new custom_time_zone(tzn2, utc_offset2, 
                                             adj_offsets2, phx_rules));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In C++03, Boost's Foreach, using this interesting technique , can detect at run-time whether
I'm writing a TCP client using boost::asio . I want to send an array
I want to add some string which I format using the boost library as
I'm using Boost.PropertyTree for a project and I want to use user-defined types for
I want to convert a string to formatted text in C# in WPF application,
I want to convert all the URLs in a javascript string to links, in
I want to convert a column of numbers to numeric, but there are certain
I want to convert a number to hex and store the result in a
I want to convert a pointer *int to its real value int , in
I want to convert plaintext to link for an input I have. The HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.