On Wed, 18 Aug 2004 20:33:10 +0100, Duncan Woods wrote
Hello All,
I'm new to Boost and interested in using it for timezone conversions but I'm not finding it terribly clear. An example, which works fine, uses something of the form:
typedef boost::date_time::local_adjustor
us_eastern;
Yes, this allows you to build static converters for a small number of time zones with well defined rules. If there isn't a rule set in the library that suits your application you would need to create one of your own. Since this is totally undocumented, I'll help you if you really want to go this way.
1. My problem is that I wish to use DST settings other than US and found definitions such as eu_dst_trait in local_timezone_defs.hpp but these seem unused and unusable. Would it require implementation of dst_rules.hpp type classes? If so, Boost would not give much advantage.
I agree date_time doesn't support local time adjustments well...yet.
2. I would also have liked to specify dst & timezone combinations at run-time which dynamic_local_time_adjustor sounds like it might do - but it appears to have no members.
It has members. Look at the bottom of libs/date_time/test/posix_time/testlocal_adjustor.cpp. Note the comment: //still experimental
3. Will date_time use the 'tz database' in the future?
The short answer is yes and I expect it before 1.33.
The long answer is that in future releases there will be a generic time_zone
class that encapsulates the glob of interfaces that the library needs to
correctly handle a time zone. The abstraction will use subclassing to support
different concrete time zone implementations. We have a working prototype now
that uses Posix timezone strings to construct. So you can do something like:
posix_time_zone arizona_tz("MST-07");
posix_time_zone ny_tz("EST-05EDT,M4.1.0,M10.5.0");
We are working on a variant that will use data from the TZ database so you can
say something like
boost::shared_ptr