你正在阅读 Celery 3.1 的文档。开发版本文档见:
此处.
celery.utils.timeutils
This module contains various utilities related to dates and times.
-
class celery.utils.timeutils.LocalTimezone[源代码]
Local time implementation taken from Python’s docs.
Used only when UTC is not enabled.
-
dst(dt)[源代码]
-
tzname(dt)[源代码]
-
utcoffset(dt)[源代码]
-
celery.utils.timeutils.maybe_timedelta(delta)[源代码]
Coerces integer to timedelta if delta is an integer.
-
celery.utils.timeutils.timedelta_seconds(delta)[源代码]
Convert datetime.timedelta to seconds.
Doesn’t account for negative values.
-
celery.utils.timeutils.delta_resolution(dt, delta)[源代码]
Round a datetime to the resolution of a timedelta.
If the timedelta is in days, the datetime will be rounded
to the nearest days, if the timedelta is in hours the datetime
will be rounded to the nearest hour, and so on until seconds
which will just return the original datetime.
-
celery.utils.timeutils.remaining(start, ends_in, now=None, relative=False)[源代码]
Calculate the remaining time for a start date and a timedelta.
e.g. “how many seconds left for 30 seconds after start?”
参数: |
- start – Start datetime.
- ends_in – The end delta as a timedelta.
- relative – If enabled the end time will be
calculated using delta_resolution() (i.e. rounded to the
resolution of ends_in).
- now – Function returning the current time and date,
defaults to datetime.utcnow().
|
-
celery.utils.timeutils.rate(rate)[源代码]
Parse rate strings, such as “100/m”, “2/h” or “0.5/s”
and convert them to seconds.
-
celery.utils.timeutils.weekday(name)[源代码]
Return the position of a weekday (0 - 7, where 0 is Sunday).
Example:
>>> weekday('sunday'), weekday('sun'), weekday('mon')
(0, 0, 1)
-
celery.utils.timeutils.humanize_seconds(secs, prefix='', sep='', now='now')[源代码]
Show seconds in human form, e.g. 60 is “1 minute”, 7200 is “2
hours”.
参数: | prefix – Can be used to add a preposition to the output,
e.g. ‘in’ will give ‘in 1 second’, but add nothing to ‘now’. |
-
celery.utils.timeutils.maybe_iso8601(dt)[源代码]
Either datetime | str -> datetime or None -> None
-
celery.utils.timeutils.is_naive(dt)[源代码]
Return True if the datetime is naive
(does not have timezone information).
-
celery.utils.timeutils.make_aware(dt, tz)[源代码]
Sets the timezone for a datetime object.
-
celery.utils.timeutils.localize(dt, tz)[源代码]
Convert aware datetime to another timezone.
-
celery.utils.timeutils.to_utc(dt)[源代码]
Converts naive datetime to UTC
-
celery.utils.timeutils.maybe_make_aware(dt, tz=None)[源代码]
-
class celery.utils.timeutils.ffwd(year=None, month=None, weeks=0, weekday=None, day=None, hour=None, minute=None, second=None, microsecond=None, **kwargs)
Version of relativedelta that only supports addition.
-
celery.utils.timeutils.utcoffset()
-
celery.utils.timeutils.adjust_timestamp(ts, offset, here=<function utcoffset at 0xb126374>)
-
celery.utils.timeutils.maybe_s_to_ms(v)