Say, if it's 13:00 at new york (EST) , then it's 06:00 at new zealand (NZST).
If new zealand goes into summer time, then when it's 13:00 at new york (still EST), it's going to be 07:00 at new zealand (now NZDT).
I read the boost time library, but it seems to me one has to determine the daylight saving rules oneself to find out the time in foreign country from the 'localtime' perspective..
e.g.
nyc_string = "EST-05:00:00EDT+01:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00";
// above basically defines the daylight saving rule
time_zone_ptr nyc_2(new posix_time_zone(nyc_string));
std::cout << "The second zone is in daylight savings from:
"
<< nyc_2->dst_local_start_time(2004) << " through "
<< nyc_2->dst_local_end_time(2004) << std::endl;
source: http://www.boost.org/doc/libs/1_39_0/doc/html/date_time/examples.html
Maybe there's something I'm not yet aware of? Does boost use any database that keeps track of daylight saving rules? I wonder if there's a nice way to adjust local time to different time zone in c++, taking the daylight saving rules into account..If I could have an example, that'd be so great!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…