Store build start/end time in UTC

Always store build times in UTC instead of local time. This may lead to
a mix of timezones since the old build times are still stored in local
time.

Change-Id: Ie0cfce385854caa5adbd27f7f13042e7bfd41f1b
This commit is contained in:
Markus Hosch 2018-04-19 15:23:54 +02:00
parent 35c2059e19
commit 752a08de57
2 changed files with 11 additions and 2 deletions

View File

@ -0,0 +1,5 @@
upgrades:
- |
The build start and end times are now stored as UTC in the database. Since
there is no localization done on zuul web side, the zuul api also exposes
these times as UTC now.

View File

@ -69,9 +69,13 @@ class SQLReporter(BaseReporter):
start = end = None
if build.start_time:
start = datetime.datetime.fromtimestamp(build.start_time)
start = datetime.datetime.fromtimestamp(
build.start_time,
tz=datetime.timezone.utc)
if build.end_time:
end = datetime.datetime.fromtimestamp(build.end_time)
end = datetime.datetime.fromtimestamp(
build.end_time,
tz=datetime.timezone.utc)
build_inserts.append({
'buildset_id': buildset_ins_result.inserted_primary_key[0],