From d5d58307d5cbafde307b3e3173e734a0278f517d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 24 Apr 2018 18:30:57 +0200 Subject: Fix git commit timestamp extraction to be (really) in UTC (I promise) --- build2/version/snapshot-git.cxx | 12 ++++++++---- 1 file 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 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 (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) { -- cgit v1.1