• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. title:: clang-tidy - abseil-duration-addition
2
3abseil-duration-addition
4========================
5
6Check for cases where addition should be performed in the ``absl::Time`` domain.
7When adding two values, and one is known to be an ``absl::Time``, we can infer
8that the other should be interpreted as an ``absl::Duration`` of a similar
9scale, and make that inference explicit.
10
11Examples:
12
13.. code-block:: c++
14
15  // Original - Addition in the integer domain
16  int x;
17  absl::Time t;
18  int result = absl::ToUnixSeconds(t) + x;
19
20  // Suggestion - Addition in the absl::Time domain
21  int result = absl::ToUnixSeconds(t + absl::Seconds(x));
22