Interface

Delorean

class delorean.dates.Delorean(datetime=None, timezone=None)

The class Delorean <Delorean> object. This method accepts naive datetime objects, with a string timezone.

date

This method returns the actual date object associated with the Delorean object.

datetime

This method returns the actual datetime object associated with the Delorean object.

epoch()

This method returns the total seconds since epoch associated with the Delorean object.

midnight()

This method returns midnight for datetime associated with the Delorean object.

naive()

Returns a naive datetime object associated with the Delorean object, this method simply converts the localize datetime to UTC and removes the tzinfo that is associated with it.

shift(tz)

This method shifts the timezone from the current timezone to the specified timezone associated with the Delorean object

timezone()

This method return a valid pytz timezone object associated with the Delorean object or raises Invalid Timezone error.

truncate(s)

Truncate the delorian object to the nearest s (second, minute, hour, day, month, year)

This is a destructive method, modifies the internal datetime object associated with the Delorean object.

delorean.dates.datetime_timezone(tz)

This method given a timezone returns a localized datetime object.

delorean.dates.get_total_second(td)

This method takes a timedelta and return the number of seconds it represents with the resolution of 10 **6

delorean.dates.is_datetime_naive(dt)

This method returns true if the datetime is naive else returns false

delorean.dates.localize(dt, tz)

Given a naive datetime object this method will return a localized datetime object

delorean.dates.move_datetime_month(dt, direction, num_shifts)

Move datetime 1 month in the chosen direction. unit is a no-op, to keep the API the same as the day case

delorean.dates.move_datetime_week(dt, direction, num_shifts)

Move datetime 1 week in the chosen direction. unit is a no-op, to keep the API the same as the day case

delorean.dates.move_datetime_year(dt, direction, num_shifts)

Move datetime 1 year in the chosen direction. unit is a no-op, to keep the API the same as the day case

delorean.dates.normalize(dt, tz)

Given a object with a timezone return a datetime object normalized to the proper timezone.

This means take the give localized datetime and returns the datetime normalized to match the specificed timezone.

Inteface Methods

delorean.interface.now()

Return a delorean object, with utcnow as the datetime

delorean.interface.parse(s, dayfirst=True, yearfirst=True)

Parses a datetime string in it and returns a Delorean object.

If a timezone is detected in the datetime string it will be normalized to UTC, and a Delorean object with that datetime and timezone will be returned.

delorean.interface.range_daily(start=None, stop=None, timezone='UTC', count=None)

This an alternative way to generating sets of Delorean objects with DAILY stops

delorean.interface.range_hourly(start=None, stop=None, timezone='UTC', count=None)

This an alternative way to generating sets of Delorean objects with HOURLY stops

delorean.interface.range_monthly(start=None, stop=None, timezone='UTC', count=None)

This an alternative way to generating sets of Delorean objects with MONTHLY stops

delorean.interface.range_yearly(start=None, stop=None, timezone='UTC', count=None)

This an alternative way to generating sets of Delorean objects with YEARLY stops

delorean.interface.stops(freq, interval=1, count=None, wkst=None, bysetpos=None, bymonth=None, bymonthday=None, byyearday=None, byeaster=None, byweekno=None, byweekday=None, byhour=None, byminute=None, bysecond=None, timezone='UTC', start=None, stop=None)

This will create a list of delorean objects the apply to setting possed in.

delorean.interface.utcnow()

Return a delorean object, with utcnow as the datetime

Delorean is a library that provides easy and convenient datetime conversions in Python. Dealing with generating lists of datetimes, timezone shifting, and much more.

Support

If you are having issues we would love to hear from you. Just hit me up. You can alternatively raise an issue here on Github.

Table Of Contents

Related Topics

Fork me on GitHub