Re: [Boost-users] Missing functions in date_time library
Just as a follow up to this, let me describe what I'm trying to do. I would like the current time in UTC with microsecond resolution. Well, the microsec_clock class only provides a local_time() method (unlike the second_clock class which also provides universal_time()). So, I need to convert the result of local_time() into UTC but I can't since the only class which knows the local timezone is c_local_adjustor and it does not provide local_to_utc() (only utc_to_local()). If there is a better way to get the current time in UTC with microsecond resolution, I'd be happy to use it instead. Thanks, Sean -----Original Message----- I'm even more confused after looking at the URL and test file you suggested. All of the examples in those documents require you to explicitly construct and provide a time zone using a name or an offset from UTC. I don't want to have to hardcode a timezone in my program -- I just want to use whatever time zone that the user has configured on their computer. The c_local_adjustor did this for me in 1.32 (although as noted in my original email, it only solves half of the problem). Perhaps I missed something in the URL you sent, but I didn't see anything in there which simply uses the timezone in use on the local machine. Thanks, Sean On Fri, 22 Jul 2005 18:09:10 -0600, Sean Rohead wrote
I am using the boost date_time library and noticed that there is a from_ftime() function to convert a FILETIME into a ptime, but I could not find the reverse operation to_ftime(). Am I missing it somewhere?
No. FILETIME, as you're certainly aware, is a Windows only way to measure time. This function is there primarily to support conversion from legacy applications. If there's really some need it's not hard to support.
Likewise, I am using the c_local_adjustor::utc_to_local() function and
cannot find the corresponding local_to_utc() function in c_local_adjustor.
In 1.33 there is vastly enhanced support for local time conversion via the timezone class and it's friends posix_timezone and tz_database. See <http://engineering.meta-comm.com/resources/cs-win32_metacomm/doc/html/d ate_time/local_time.html#date_time.local_time.time_zone_base> for more on this. If you still want to use the compile time approach supported in 1.32, have a look at libs/date_time/test/posix_time/testlocal_adjustor.cpp. There's code in there that show how to convert back and forth. Jeff _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Thu, 28 Jul 2005 13:51:06 -0600, Sean Rohead wrote
Just as a follow up to this, let me describe what I'm trying to do. I would like the current time in UTC with microsecond resolution. Well, the microsec_clock class only provides a local_time() method (unlike the second_clock class which also provides universal_time() ). So, I need to convert the result of local_time() into UTC but I can't since the only class which knows the local timezone is c_local_adjustor and it does not provide local_to_utc() (only utc_to_local()).
If there is a better way to get the current time in UTC with microsecond resolution, I'd be happy to use it instead.
That was an omission that is fixed in the current CVS. So in 1.33, which should be shipping in the next few days, you can just call universal_time(). Jeff
participants (2)
-
Jeff Garland
-
Sean Rohead