• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. title:: clang-tidy - abseil-time-comparison
2
3abseil-time-comparison
4======================
5
6Prefer comparisons in the ``absl::Time`` domain instead of the integer domain.
7
8N.B.: In cases where an ``absl::Time`` is being converted to an integer,
9alignment may occur. If the comparison depends on this alignment, doing the
10comparison in the ``absl::Time`` domain may yield a different result. In
11practice this is very rare, and still indicates a bug which should be fixed.
12
13Examples:
14
15.. code-block:: c++
16
17  // Original - Comparison in the integer domain
18  int x;
19  absl::Time t;
20  if (x < absl::ToUnixSeconds(t)) ...
21
22  // Suggested - Compare in the absl::Time domain instead
23  if (absl::FromUnixSeconds(x) < t) ...
24