Re: [boost] date_time: second_clock and microsec_clock errors

[mailto:boost-bounces@lists.boost.org]On Behalf Of Jeff Garland
[micro]second_clock< boost::local_time::local_date_time_base<> > could not be compiled. The problematic function is: private: static time_type create_time(::std::tm* current);
The error is that local_date_time_base<> does not have constructors that takes date and time duration.
It's not really a problem. With local_time you need to provide a timezone pointer to get a time value. So you call it like this: //get time in new york time zone: boost::shared_ptr<time_zone> ny_tz(new posix_time_zone("EST-05EDT,M4.1.0,M10.5.0"));
local_date_time ldt3 = local_microsec_clock::local_time(ny_tz);
You'll note that there is another overloading in clock classes for this case:
template<class time_zone_type> static time_type local_time(shared_ptr<time_zone_type> tz_ptr);
Yes, I discovered work around few days ago. I posted the error here, because I think that this error indicates, that something wrong with design. I think that date_time library should define local_microsec_clock, not in terms of microsec_clock, but using an other class that is aware of time zone. Why is microsec_clock class not aware of time zones?
Jeff
Thanks Roman Yakovenko

On Mon, 28 Nov 2005 15:20:47 +0200, Roman Yakovenko wrote
[mailto:boost-bounces@lists.boost.org]On Behalf Of Jeff Garland
[micro]second_clock< boost::local_time::local_date_time_base<> > could not be compiled. The problematic function is: private: static time_type create_time(::std::tm* current);
The error is that local_date_time_base<> does not have constructors that takes date and time duration.
It's not really a problem. With local_time you need to provide a timezone pointer to get a time value. So you call it like this: //get time in new york time zone: boost::shared_ptr<time_zone> ny_tz(new posix_time_zone("EST-05EDT,M4.1.0,M10.5.0"));
local_date_time ldt3 = local_microsec_clock::local_time(ny_tz);
You'll note that there is another overloading in clock classes for this case:
template<class time_zone_type> static time_type local_time(shared_ptr<time_zone_type> tz_ptr);
Yes, I discovered work around few days ago. I posted the error here, because I think that this error indicates, that something wrong with design.
Anything's possible ;-)
I think that date_time library should define local_microsec_clock, not in terms of microsec_clock, but using an other class that is aware of time zone.
Why is microsec_clock class not aware of time zones?
I'll turn it around the other way. Most instances of microsecond_clock never care about the a time_zone to adjust the time. So there is no reason to drag in that dependency. But, in fact, the overloading I pointed out above: template<class time_type> class microsecond_clock { ... template<class time_zone_type> static time_type local_time(shared_ptr<time_zone_type> tz_ptr); enables the microsecond clock to use a time zone. When using a local_date_time type the timezone is required. So it's true, you'll get a compile error if you try to call the other overloadings with a local_date_time, but that's the intent. Jeff
participants (2)
-
Jeff Garland
-
Roman Yakovenko