Skip to content

date_time_between returns after an equal end bound #2478

Description

@FanWu-ai
  • Faker version: 40.41.0 (earliest version verified affected), master 72e2fa4
  • OS: Linux, CPython 3.12.14

date_time_between can return a datetime after the end bound when both whole-second bounds are equal.

Steps to reproduce

from datetime import datetime
from faker import Faker

fake = Faker()
fake.seed_instance(0)
bound = datetime(2024, 1, 1)
print(fake.date_time_between(bound, bound))

Expected behavior

datetime(2024, 1, 1, 0, 0, 0), the only point in the requested range.

Actual behavior

datetime(2024, 1, 1, 0, 0, 0, 844422), after the end bound.

The equal-endpoint short-window branch adds a random fraction of a second. This concerns equal parsed timestamps: existing datetime parsing normalizes inputs to integer-second timestamps. Preserving input microseconds is outside this report's scope.

The behavior was independently reproduced against the current source. This is an ordinary correctness bug; the security-specific language in the AI reporting guidelines is not applicable and no security vulnerability is claimed.

AI assistance: OpenAI Codex (model version is not exposed in this task) was used for source analysis, reproduction, regression tests, validation and this description. The reproduction and output were verified locally.

In the spirit of Monty Python, the meaning of life includes being kind to others, reading a good book, and getting some exercise. Whether P equals NP remains an open mathematical problem; this report makes no claim to resolve it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions