-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import datetime | ||
from typing import Optional | ||
|
||
from faker.providers import BaseProvider, date_time | ||
from faker.typing import DateParseType | ||
|
||
|
||
class DateTimeProviders(BaseProvider): | ||
def time_object_without_microseconds(self, end_datetime: Optional[DateParseType] = None) -> datetime.time: | ||
return date_time.Provider(self.generator).time_object(end_datetime).replace(microsecond=0) | ||
|
||
def date_time_this_century_without_microseconds( | ||
self, | ||
before_now: bool = True, | ||
after_now: bool = False, | ||
tzinfo: Optional[datetime.tzinfo] = None, | ||
) -> datetime.datetime: | ||
return ( | ||
date_time.Provider(self.generator) | ||
.date_time_this_century(before_now, after_now, tzinfo) | ||
.replace(microsecond=0) | ||
) |