-
Notifications
You must be signed in to change notification settings - Fork 523
Description
I have a small library of date/datetime helpers (creatively called datestuff that I'd like to donate to this library. I often find myself installing both side by side and I feel the tools in datestuff are a good fit for dateutils' goal of "Useful extensions to the standard Python datetime features"
A quick rundown:
-
RelativeDateandRelativeDateTimeprovide "unfixed" dates/datetimes. What this means is that when the class is created, it's not tied to a specific instance in time but rather to an offset. Allowing a user to create a date that is always 1 week from now is as easy asRelativeDateTime(offset=timedelta(days=7))rather than needing to deal withdatetime.now() + timedelta(days=7)all over the place, the added benefit is that these can be used where ever regular date/datetime objects are. They also accept a factory if a different date/datetime object is desired.RelativeDate(Time)is already compatible withrelativedeltaas well. -
DateRangeis a range of date/datetimes modeled after Python 3's range so it is lazy, slicing it results in a new range rather than a list and has fast path membership testing. I've never found a helper than scratched this itch for me. The existingrruleis nice, but seems more suitable for complex calendar scheduling than a range of dates. Where asDateRangeis simple to use: Just give it a start date, an optional end date, and a timedelta to step by. I will say allowing both fixed and infinite ranges from the same object was probably a mistake and it does complicate the code some. -
within_deltais helper I wrote because I got tired of normalizing datetimes before comparing them.
If any copyright/license stuff needs to be signed over, I'm happy to do that (never done something like before).