aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-04-24 18:30:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-04-24 18:30:57 +0200
commitd5d58307d5cbafde307b3e3173e734a0278f517d (patch)
tree32e4abc269194dfbb9cf0faf541961109d96a8d1
parent84e26884cbbc692062c20798fc12cd90ca4383c4 (diff)
Fix git commit timestamp extraction to be (really) in UTC (I promise)
-rw-r--r--build2/version/snapshot-git.cxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/build2/version/snapshot-git.cxx b/build2/version/snapshot-git.cxx
index 751686e..a8b9330 100644
--- a/build2/version/snapshot-git.cxx
+++ b/build2/version/snapshot-git.cxx
@@ -90,10 +90,11 @@ namespace build2
// committer John Doe <john@example.org> 1493117819 +0200
//
// The timestamp is in seconds since UNIX epoch. The timezone
- // appears to be always numeric (+0000 for UTC).
+ // appears to be always numeric (+0000 for UTC). Note that
+ // timestamp appears to be already in UTC with timezone being just
+ // for information it seems.
//
size_t p1 (l.rfind (' ')); // Can't be npos.
- string tz (l, p1 + 1);
size_t p2 (l.rfind (' ', p1 - 1));
if (p2 == string::npos)
@@ -102,6 +103,9 @@ namespace build2
string ts (l, p2 + 1, p1 - p2 - 1);
time_t t (static_cast<time_t> (stoull (ts)));
+#if 0
+ string tz (l, p1 + 1);
+
if (tz.size () != 5)
throw invalid_argument ("invalid timezone");
@@ -118,13 +122,13 @@ namespace build2
case '-': t += s; break;
default: throw invalid_argument ("invalid timezone sign");
}
-
+#endif
// Represent as YYYYMMDDhhmmss.
//
r.sn = stoull (to_string (system_clock::from_time_t (t),
"%Y%m%d%H%M%S",
false /* special */,
- true /* local (already in UTC) */));
+ false /* local (already in UTC) */));
}
catch (const invalid_argument& e)
{