[date_time] local_time_period between two different time zones
I want to calculate the time difference between local_date_time objects that I
initialized using two different time zones:
#include <iostream>
#include
Alberto Giannetti escribió:
I want to calculate the time difference between local_date_time objects that I initialized using two different time zones:
...
time_zone_ptr tzp_nyc = tz_db.time_zone_from_region("America/New_York"); time_zone_ptr tzp_rome = tz_db.time_zone_from_region("Europe/Rome");
local_date_time nyc_time(second_clock::universal_time(), tzp_nyc); // #1 ... local_date_time rome_time(second_clock::universal_time(), tzp_rome); // #2 ...
tdiff.lenth() returns 00:00:00. Why the function can't return the difference between the two local times?
I don't even read the Boost.Date_Time documentation, so maybe my response is going to be a nonsense, but nobody is answering, so I'll give it a try... I think that second_clock::universal_time() is returning the same time in lines #| and #2. Your computer clock is the same, whether you are in New York or in Rome. It is when you call to_simple_string(...local_time()) when this same time gets represented as NewYork time or Rome time. Now in Roma it is 21:00 h, but in New York it is 15:00. The universal time it's the same, but gets "changed" when you call to_simple_string. So if you try to diff the two times, you get 00:00:00. It seems logical to me... ;) Hope it helps (and excuse my poor English), Raul.
participants (2)
-
Alberto Giannetti
-
Raúl Huertas