Overall Index -- Gregorian Index -- Posix Time Index
Local Time Adjustment
Header -- Class Overview --
A frequent problem in time representation is the conversion between various local time systems. In general this is accomplished by using a reference time system. The reference time system is typically UTC.
Since the posix_time system does no internal time adjustment it can be used to represent both local times and UTC times. However, the user is currently left to handle conversions and time zone knowledge explicitly.
The library offers two different ways to perform UTC to local conversions. The first is using the time zone settings of the computer. This is a useful solution for converting a UTC time for a user machine. This approach depends on the ctime API and will provide incorrect results if the environment is set incorrectly. The other approach allows conversion from any zone to UTC and back independent of the settings of the time zone settings of the computer. The local utc conversion example demonstrates both of these techniques.
#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o or #include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
|date_time::c_local_adjustor<ptime>::utc_to_local(ptime)||Calculate local machine time from a UTC time based on time zone settings and the C API.||
typedef boost::date_time::c_local_adjustor<ptime> local_adj;|
ptime t10(date(2002,Jan,1), hours(7));
ptime t11 = local_adj::utc_to_local(t10);
|date_time::local_adjustor<ptime, utc_offset, dst_rules>::utc_to_local(ptime)||Calculate local machine time from a UTC time based daylight savings rules and utc offset||example|
|date_time::local_adjustor<ptime, utc_offset, dst_rules>::local_to_utc(ptime)||Calculate UTC time based on daylight savings rules and utc offset.||example|