Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3336: utc offset calculated wrong
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-04-27 15:42:05
#3336: utc offset calculated wrong
----------------------------------+-----------------------------------------
Reporter: silvan@⦠| Owner: az_sw_dude
Type: Bugs | Status: new
Milestone: Boost 1.40.0 | Component: date_time
Version: Boost 1.38.0 | Severity: Problem
Keywords: |
----------------------------------+-----------------------------------------
Comment(by Jason Pettiss <jpettiss@â¦>):
The UTC offset in POSIX 1003.1 section 8.3 TZ strings is inverted from
that in Olson TZ database strings, which is a cause for confusion. The
former treats UTC as relative to the local time, i.e what do we add to the
''local'' wall clock to produce the wall clock time in UTC. The latter
treats the local time as relative to UTC, as in, what do we add to the
time in UTC to get to the local time.
The man pages for tzset(3) seem pretty consistent although some are
clearer than others. I like this wording best, myself:
offset:: Indicates the value one must add to the local time to arrive at
Coordinated Universal Time.
Sun is their own celestial body but they see it the same way:
http://docs.sun.com/source/816-5523-10/appf.htm
||USA (Eastern) ||EST5EDT
||Russia (Moscow) ||MST-3MDT
Here also, positive is west of Greenwich, negative is east of it.
As a hacky workaround, the string can be manipulated prior to feeding it
to posix_time_zone. Find the first [0-9+-]. If we're not at the end of
the string, if '+' change to '-' and vice versa. Otherwise insert '-'
before the current position. Something like the following (untested!):
{{{
void fliptzoffset(std::string& tzstr) {
std::string::iterator i = tzstr.begin(), e = tzstr.end();
while (i != e && !isdigit(*i) && '+'!=*i && '-'!=*i) ++i;
if (i == e) return;
if ('-' == *i) *i = '+';
else if ('+' == *i) *i = '-';
else tzstr.insert(i, '-');
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/3336#comment:2> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:03 UTC