[Boost-bugs] [ boost-Bugs-1220011 ] local_adjustor::utc_to_local throws "Time label invalid"

Bugs item #1220011, was opened at 2005-06-13 15:25 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1220011&group_id=7586 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: date_time Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Jeff Garland (az_sw_dude) Summary: local_adjustor::utc_to_local throws "Time label invalid" Initial Comment: using namespace boost::posix_time; using namespace boost::date_time; using namespace boost::gregorian; ptime datetime( date( 2005, 4, 2 ), time_duration( 23, 0, 0 ) ); typedef local_adjustor< ptime, 3, us_dst > adj; ptime adj_time( adj::utc_to_local( datetime ) ); // Fails with "Time label invalid" Compiled on boost 1.32.0 with msvc++ 7.1.3088 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1220011&group_id=7586 ------------------------------------------------------- This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput a projector? How fast can you ride your desk chair down the office luge track? If you want to score the big prize, get to know the little guy. Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20 _______________________________________________ Boost-bugs mailing list Boost-bugs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/boost-bugs

Submitted By: Nobody/Anonymous (nobody) Assigned to: Jeff Garland (az_sw_dude) Summary: local_adjustor::utc_to_local throws "Time label invalid"
Initial Comment: using namespace boost::posix_time; using namespace boost::date_time; using namespace boost::gregorian;
ptime datetime( date( 2005, 4, 2 ), time_duration( 23, 0, 0 ) ); typedef local_adjustor< ptime, 3, us_dst > adj; ptime adj_time( adj::utc_to_local( datetime ) ); // Fails with "Time label invalid"
Compiled on boost 1.32.0 with msvc++ 7.1.3088
This is correct. Since the date and UTC offset you gave would end up right on the transition into dst, it is considered an invalid time label. I believe we are going to depricate this code (local_adjustor). With version 1.33 we've introduced a local_date_time. Here's an example showing how to accomplish the above calculation: #include <iostream> #include <boost/date_time/local_time/local_time.hpp> int main() { using namespace boost::gregorian; using namespace boost::posix_time; using namespace boost::local_time; ptime datetime_1(date(2005, 4, 2), time_duration(22, 59, 59) ); ptime datetime_2(date(2005, 4, 2), time_duration(23, 0, 0) ); time_zone_ptr my_zone(new posix_time_zone("STD03DST,M4.1.0,M10.1.0")); local_date_time ldt_1(datetime_1, my_zone); // given ptime is UTC local_date_time ldt_2(datetime_2, my_zone); // given ptime is UTC std::cout << ldt_1.local_time() << std::endl; // "2005-Apr-03 01:59:59" <- not dst std::cout << ldt_2.local_time() << std::endl; // "2005-Apr-03 03:00:00" <- in dst } Current cvs is already capable of this. Hope this helps, Bart
participants (2)
-
Bart
-
SourceForge.net