Boost logo

Boost Users :

Subject: [Boost-users] [date_time] dst_local_start_time
From: Jean-Pierre Bergamin (james_at_[hidden])
Date: 2008-11-05 08:20:05


I'm confused about the returned time of the dst_local_start_time()
function. First of all I don't understand why a ptime is returned and
not a local_date_time, buy anyway.

The ptime I get returned for the timezone Europe/Zurich for 2007 is:
2007-Mar-25 02:00:00
Assuming that this is a UTC time, the local time in Zurich would then be
2007-Mar-25 04:00:00 (because during summertime, Zurich is 2h ahead of
UTC), but the correct local dst start time would be 2007-Mar-25 03:00:00
(because the clocks are shifted from 2 to 3).
To correctly calculate the dst start time, I have to add the dst_offset
to the returned time_of_day.

The returned ptime 2007-Mar-25 02:00:00 seems to be the endtime of
wintertime as a local time.

time_zone_ptr zh_tz = tz_db.time_zone_from_region("Europe/Zurich");
ptime zh_dst_start_time = zh_tz->dst_local_start_time(2007);
std::cout << zh_dst_start_time << std::endl; // 2007-Mar-25 02:00:00
local_date_time zh_dst_local_start_time =
local_date_time(zh_dst_start_time, zh_tz);
std::cout << zh_dst_local_start_time << std::endl; // 2007-Mar-25
04:00:00 CEST which is wrong!

ptime zh_dst_start_time_ok = zh_dst_start_time + zh_tz->dst_offset();
local_date_time zh_dst_local_start_time_ok =
zh_dst_start_time_ok.time_of_day(), zh_tz, true);
std::cout << zh_dst_local_start_time_ok << std::endl; // 2007-Mar-25
03:00:00 CEST which is correct

So what time exactly is local_start_time() returning?
Is this a bug or am I missing something?



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at