Skip to content

Feature/future past datetime methods#1693

Open
rodrigobnogueira wants to merge 1 commit intolk-geimfari:masterfrom
rodrigobnogueira:feature/future-past-datetime-methods
Open

Feature/future past datetime methods#1693
rodrigobnogueira wants to merge 1 commit intolk-geimfari:masterfrom
rodrigobnogueira:feature/future-past-datetime-methods

Conversation

@rodrigobnogueira
Copy link
Copy Markdown

I have made things!

Checklist

  • I'm sure that I did not unrelated changes in this pull request
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.rst

Related issues

Description

Add methods to generate dates and datetimes relative to the current time for the Datetime provider:

Method Description
future_date(days=30) Random date between tomorrow and N days in the future
future_datetime(days=30, timezone=None) Random datetime from now+1s to N days ahead
past_date(days=30) Random date between N days ago and yesterday
past_datetime(days=30, timezone=None) Random datetime from N days ago to now-1s

Usage Examples

from mimesis import Datetime

dt = Datetime()

# Future dates
dt.future_date()            # Random date 1-30 days from now
dt.future_date(days=7)      # Random date 1-7 days from now
dt.future_datetime()        # Random datetime 1s-30d from now
dt.future_datetime(timezone="Europe/Paris")

# Past dates
dt.past_date()              # Random date 1-30 days ago
dt.past_date(days=7)        # Random date 1-7 days ago
dt.past_datetime()          # Random datetime 1s-30d ago
dt.past_datetime(timezone="Europe/Paris")

Tests

All 8765 tests pass, including:

  • Functional tests for all 4 methods (parameterized for different days values and timezones)
  • Seeded reproducibility tests

@rodrigobnogueira rodrigobnogueira force-pushed the feature/future-past-datetime-methods branch 4 times, most recently from f755a0f to c93867f Compare January 12, 2026 22:37
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.92%. Comparing base (876b939) to head (73d1613).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1693      +/-   ##
==========================================
+ Coverage   98.91%   98.92%   +0.01%     
==========================================
  Files          50       50              
  Lines        2114     2144      +30     
==========================================
+ Hits         2091     2121      +30     
  Misses         23       23              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rodrigobnogueira rodrigobnogueira force-pushed the feature/future-past-datetime-methods branch from c93867f to d25ca68 Compare January 12, 2026 22:45
Comment thread mimesis/providers/date.py
Comment thread mimesis/providers/date.py
@rodrigobnogueira rodrigobnogueira force-pushed the feature/future-past-datetime-methods branch from d25ca68 to b5efd09 Compare January 13, 2026 15:17
Add methods to generate dates and datetimes relative to the current time:
- future_date(days=30): Random date between tomorrow and N days ahead
- future_datetime(days=30, timezone=None): Random datetime from now+1s to N days ahead
- past_date(days=30): Random date between N days ago and yesterday
- past_datetime(days=30, timezone=None): Random datetime from N days ago to now-1s

Closes lk-geimfari#775
@rodrigobnogueira rodrigobnogueira force-pushed the feature/future-past-datetime-methods branch from b5efd09 to 73d1613 Compare January 13, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add future and past providers to datetime

2 participants