Skip to content

Commit 26df9dd

Browse files
committed
Simplify clamping of tricky-draw windows
1 parent 6e9b745 commit 26df9dd

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • hypothesis/src/hypothesis/strategies/_internal

‎hypothesis/src/hypothesis/strategies/_internal/datetime.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,8 @@ def draw_tricky_datetime(self, data, tz):
529529
)
530530
lo, hi = (_as_naive_datetime(b) for b in window)
531531
center = min(max(instant, lo), hi)
532-
low = center - width if center - lo >= width else lo
533-
high = center + width if hi - center >= width else hi
532+
low = center - min(width, center - lo)
533+
high = center + min(width, hi - center)
534534
result = draw_capped_multipart(data, low, high)
535535
value = replace_tzinfo(dt.datetime(**result), timezone=tz)
536536
if self.aware and not self.in_bounds(value):

0 commit comments

Comments
 (0)