blob: 3ac318e6c9a72bce96252faca32d6b29c8588b73 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2011 The Chromium Authors
[email protected]08aa02762011-11-11 16:09:312// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
danakj0a448602015-03-10 00:31:165#ifndef BASE_BUILD_TIME_H_
6#define BASE_BUILD_TIME_H_
[email protected]08aa02762011-11-11 16:09:317
Will Harris064192c2023-03-16 17:34:508#include "base/generated_build_date.h"
[email protected]99084f62013-06-28 00:49:079#include "base/time/time.h"
[email protected]08aa02762011-11-11 16:09:3110
11namespace base {
12
zforman08d91b72016-02-12 06:23:4213// GetBuildTime returns the time at which the current binary was built,
14// rounded down to 5:00:00am at the start of the day in UTC.
[email protected]08aa02762011-11-11 16:09:3115//
zforman08d91b72016-02-12 06:23:4216// This uses a generated file, which doesn't trigger a rebuild when the time
17// changes. It will, however, be updated whenever //build/util/LASTCHANGE
18// changes.
[email protected]08aa02762011-11-11 16:09:3119//
zforman08d91b72016-02-12 06:23:4220// This value should only be considered accurate to within a day.
21// It will always be in the past.
sebmarchand153e1b82014-10-31 20:25:5222//
zforman08d91b72016-02-12 06:23:4223// Note: If the build is not official (i.e. is_official_build = false)
24// this time will be set to 5:00:00am on the most recent first Sunday
25// of a month.
Will Harris064192c2023-03-16 17:34:5026constexpr Time GetBuildTime() {
27 // BASE_GENERATED_BUILD_DATE_TIMESTAMP is a Unix timestamp value. See
28 // //base/write_build_date_header.py and //build/compute_build_timestamp.py
29 // for details. On non-official builds, this will be first Sunday of the month
30 // at 5:00am UTC.
31 return Time::FromTimeT(BASE_GENERATED_BUILD_DATE_TIMESTAMP);
32}
[email protected]08aa02762011-11-11 16:09:3133
34} // namespace base
35
danakj0a448602015-03-10 00:31:1636#endif // BASE_BUILD_TIME_H_