_const.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (c) 2025-2026 Buf Technologies, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from __future__ import annotations
  15. from datetime import datetime, timedelta, timezone
  16. SECOND_AS_NANOS = 1_000_000_000
  17. """One second as nano seconds."""
  18. DURATION_SECONDS_MAX = 315_576_000_000
  19. """Maximum/minimum seconds for Duration and Timestamp (representing +/-10,000 years)."""
  20. NANOS_PER_SECOND_MAX = 999_999_999
  21. """Maximum nanosecond value within a second."""
  22. EPOCH_DATETIME = datetime(1970, 1, 1, tzinfo=timezone.utc)
  23. """Epoch represented in datetime."""
  24. MICROSECOND_DELTA = timedelta(microseconds=1)
  25. """One microsecond represented in timedelta."""
  26. MAX_NANOS = 253_402_300_799_999_999_000
  27. """Largest legal value for nanoseconds"""
  28. MIN_NANOS = -62_135_596_800_000_000_000
  29. """Smallest legal value for nanoseconds"""