Trees Indices Help
Trac
Package trac :: Package util :: Module datefmt

Module datefmt

source code

Classes
FixedOffset
Fixed offset in minutes east from UTC.
LocalTimezone
A 'local' time zone implementation
Functions
to_datetime(t, tzinfo=None)
Convert ``t`` into a `datetime` object in the ``tzinfo`` timezone. source code
to_timestamp(dt)
Return the corresponding POSIX timestamp source code
to_utimestamp(dt)
Return a microsecond POSIX timestamp for the given datetime. source code
from_utimestamp(ts)
Return the datetime for the given microsecond POSIX timestamp. source code
pretty_timedelta(time1, time2=None, resolution=None)
Calculate time delta between two datetime objects. source code
format_datetime(t=None, format='%x %X', tzinfo=None)
Format the datetime object t into an unicode string source code
format_date(t=None, format='%x', tzinfo=None)
Convenience method for formatting the date part of a datetime object. source code
format_time(t=None, format='%X', tzinfo=None)
Convenience method for formatting the time part of a datetime object. source code
get_date_format_hint()
Present the default format used by format_date in a human readable form. source code
get_datetime_format_hint()
Present the default format used by format_datetime in a human readable form. source code
http_date(t=None)
Format datetime object t as a rfc822 timestamp source code
parse_date(text, tzinfo=None, hint='date') source code
timezone(tzname)
Fetch timezone instance by name or raise KeyError source code
get_timezone(tzname)
Fetch timezone instance by name or return None source code
Variables
utc = <FixedOffset "UTC" 0:00:00>
utcmin = datetime.datetime(1, 1, 1, 0, 0, tzinfo=<FixedOffset ...
utcmax = datetime.datetime(9999, 12, 31, 23, 59, 59, 999999, t...
localtz = <LocalTimezone "CET" 1:00:00 "CEST" 2:00:00>
STDOFFSET = datetime.timedelta(0, 3600)
DSTOFFSET = datetime.timedelta(0, 7200)
DSTDIFF = datetime.timedelta(0, 3600)
all_timezones = ['Africa/Abidjan', 'Africa/Accra', 'Africa/Add...
__package__ = 'trac.util'
tz = <FixedOffset "GMT +13:00" 13:00:00>
tzname = 'UTC'
z = <FixedOffset "GMT +13:00" 13:00:00>

Imports: locale, math, re, sys, time, tzinfo, timedelta, datetime, date, TracError, to_unicode, getpreferredencoding, _, ngettext, bisect, pytz


Function Details

to_datetime(t, tzinfo=None)

source code
Convert ``t`` into a `datetime` object in the ``tzinfo`` timezone.
If no ``tzinfo`` is given, the local timezone `localtz` will be used.
``t`` is converted using the following rules:
 - If ``t`` is already a `datetime` object,
 - if it is timezone-"naive", it is localized to ``tzinfo``
 - if it is already timezone-aware, ``t`` is mapped to the given
 timezone (`datetime.datetime.astimezone`)
 - If ``t`` is None, the current time will be used.
 - If ``t`` is a number, it is interpreted as a timestamp.
Any other input will trigger a `TypeError`.
All returned datetime instances are timezone aware and normalized.

pretty_timedelta(time1, time2=None, resolution=None)

source code

Calculate time delta between two datetime objects. (the result is somewhat imprecise, only use for prettyprinting).

If either time1 or time2 is None, the current time will be used instead.

format_datetime(t=None, format='%x %X', tzinfo=None)

source code

Format the datetime object t into an unicode string

If t is None, the current time will be used.

The formatting will be done using the given format, which consist of conventional strftime keys. In addition the format can be 'iso8601' to specify the international date format (compliant with RFC 3339).

tzinfo will default to the local timezone if left to None.

format_date(t=None, format='%x', tzinfo=None)

source code
Convenience method for formatting the date part of a datetime object. See format_datetime for more details.

format_time(t=None, format='%X', tzinfo=None)

source code
Convenience method for formatting the time part of a datetime object. See format_datetime for more details.

get_date_format_hint()

source code
Present the default format used by format_date in a human readable form. This is a format that will be recognized by parse_date when reading a date.

get_datetime_format_hint()

source code
Present the default format used by format_datetime in a human readable form. This is a format that will be recognized by parse_date when reading a date.

Variables Details

utcmin

Value:
datetime.datetime(1, 1, 1, 0, 0, tzinfo=<FixedOffset "UTC" 0:00:00>)

utcmax

Value:
datetime.datetime(9999, 12, 31, 23, 59, 59, 999999, tzinfo=<FixedOffse\
t "UTC" 0:00:00>)

all_timezones

Value:
['Africa/Abidjan',
 'Africa/Accra',
 'Africa/Addis_Ababa',
 'Africa/Algiers',
 'Africa/Asmara',
 'Africa/Bamako',
 'Africa/Bangui',
 'Africa/Banjul',
...

Trees Indices Help
Trac

AltStyle によって変換されたページ (->オリジナル) /