Class v.c.e.e.Time(object):

Part of vmc.contrib.epsilon.extime View In Hierarchy

An object representing a well defined instant in time.

A Time object unambiguously addresses some time, independent of timezones, contorted base-60 counting schemes, leap seconds, and the effects of general relativity. It provides methods for returning a representation of this time in various ways that a human or a programmer might find more useful in various applications.

Every Time instance has an attribute 'resolution'. This can be ignored, or the instance can be considered to address a span of time. This resolution is determined by the value used to initalize the instance, or the resolution of the internal representation, whichever is greater. It is mostly useful when using input formats that allow the specification of whole days or weeks. For example, ISO 8601 allows one to state a time as, "2005-W03", meaning "the third week of 2005". In this case the resolution is set to one week. Other formats are considered to express only an instant in time, such as a POSIX timestamp, because the resolution of the time is limited only by the hardware's representation of a real number.

Timezones are significant only for instances with a resolution greater than one day. When the timezone is insignificant, the result of methods like asISO8601TimeAndDate is the same for any given tzinfo parameter. Sort order is determined by the start of the period in UTC. For example, "today" sorts after "midnight today, central Europe", and before "midnight today, US Eastern". For applications that need to store a mix of timezone dependent and independent instances, it may be wise to store them separately, since the time between the start and end of today in the local timezone may not include the start of today in UTC, and thus not independent instances addressing the whole day. In other words, the desired sort order (the one where just "Monday" sorts before any more precise time in "Monday", and after any in "Sunday") of Time instances is dependant on the timezone context.

Date arithmetic and boolean operations operate on instants in time, not periods. In this case, the start of the period is used as the value, and the result has a resolution of 0.

For containment tests with the 'in' operator, the period addressed by the instance is used.

The methods beginning with 'from' are constructors to create instances from various formats. Some of them are textual formats, and others are other time types commonly found in Python code.

Likewise, methods beginning with 'as' return the represented time in various formats. Some of these methods should try to reflect the resolution of the instance. However, they don't yet.

For formats with both a constructor and a formatter, d == fromFu(d.asFu())
Instance Variablesresolutionthe length of the period to which this instance could refer. For example, "Today, 13:38" could refer to any time between 13:38 until but not including 13:39. In this case resolution would be timedelta(minutes=1). (type: datetime.timedelta )
Method __init__ Return a new Time instance representing the time now.
Class Method fromHumanly Return a new Time instance from a string a human might type.
Class Method fromISO8601TimeAndDate Return a new Time instance from a string formated as in ISO 8601.
Class Method fromStructTime Return a new Time instance from a time.struct_time.
Class Method fromDatetime Return a new Time instance from a datetime.datetime instance.
Class Method fromPOSIXTimestamp Return a new Time instance from seconds since the POSIX epoch.
Class Method fromRFC2822 Return a new Time instance from a string formated as described in RFC 2822.
Method asPOSIXTimestamp Return this time as a timestamp as specified by POSIX.
Method asDatetime Return this time as an aware datetime.datetime instance.
Method asNaiveDatetime Return this time as a naive datetime.datetime instance.
Method asRFC2822 Return this Time formatted as specified in RFC 2822.
Method asISO8601TimeAndDate Return this time formatted as specified by ISO 8861.
Method asStructTime Return this time represented as a time.struct_time.
Method asHumanly Return this time as a short string, tailored to the current time.
Method getBounds Return a pair describing the bounds of self.
Method oneDay Return a Time instance representing the day of the start of self.
Method isAllDay Return True iff this instance represents exactly all day.
Method isTimezoneDependent Return True iff timezone is relevant for this instance.
Method __cmp__ Undocumented
Method __eq__ Undocumented
Method __ne__ Undocumented
Method __repr__ Undocumented
Method __contains__ Test if another Time instance is entirely within the period addressed by this one.
Method __add__ Undocumented
Method __sub__ Implement subtraction of an interval or another time from this one.
def __init__(self):

Return a new Time instance representing the time now.

See also the fromFu methods to create new instances from other types of initializers.
@classmethod
def _fromWeekday(klass, match, tzinfo, now):
Undocumented
@classmethod
def _fromTodayOrTomorrow(klass, match, tzinfo, now):
Undocumented
@classmethod
def _fromTime(klass, match, tzinfo, now):
Undocumented
@classmethod
def _fromNoonOrMidnight(klass, match, tzinfo, now):
Undocumented
@classmethod
def _fromNow(klass, match, tzinfo, now):
Undocumented
@classmethod
def fromHumanly(klass, humanStr, tzinfo=None, now=None):
Return a new Time instance from a string a human might type.
ParametershumanStrthe string to be parsed.
tzinfoA tzinfo instance indicating the timezone to assume if none is specified in humanStr. If None, assume UTC.
now

A Time instance to be considered "now" for when interpreting relative dates like "tomorrow". If None, use the real now.

Total crap now, it just supports weekdays, "today" and "tomorrow" for now. This is pretty insufficient and useless, but good enough for some demo functionality, or something.
@classmethod
def fromISO8601TimeAndDate(klass, iso8601string, tzinfo=None):

Return a new Time instance from a string formated as in ISO 8601.

If the given string contains no timezone, it is assumed to be in the timezone specified by the parameter `tzinfo`, or UTC if tzinfo is None. An input string with an explicit timezone will always override tzinfo.

If the given iso8601string does not contain all parts of the time, they will default to 0 in the timezone given by `tzinfo`.

WARNING: this function is incomplete. ISO is dumb and their standards are not free. Only a subset of all valid ISO 8601 dates are parsed, because I can't find a formal description of the format. However, common ones should work.
@classmethod
def fromStructTime(klass, structTime, tzinfo=None):

Return a new Time instance from a time.struct_time.

If tzinfo is None, structTime is in UTC. Otherwise, tzinfo is a datetime.tzinfo instance coresponding to the timezone in which structTime is.

Many of the functions in the standard time module return these things. This will also work with a plain 9-tuple, for parity with the time module. The last three elements, or tm_wday, tm_yday, and tm_isdst are ignored.
@classmethod
def fromDatetime(klass, dtime):

Return a new Time instance from a datetime.datetime instance.

If the datetime instance does not have an associated timezone, it is assumed to be UTC.
@classmethod
def fromPOSIXTimestamp(klass, secs):

Return a new Time instance from seconds since the POSIX epoch.

The POSIX epoch is midnight Jan 1, 1970 UTC. According to POSIX, leap seconds don't exist, so one UTC day is exactly 86400 seconds, even if it wasn't.
Parameterssecsa number of seconds, represented as an integer, long or float.
@classmethod
def fromRFC2822(klass, rfc822string):
Return a new Time instance from a string formated as described in RFC 2822.
Parametersrfc822string (type: str )
Returnsa new Time
RaisesValueErrorif the timestamp is not formatted properly (or if certain obsoleted elements of the specification are used).
def asPOSIXTimestamp(self):

Return this time as a timestamp as specified by POSIX.

This timestamp is the count of the number of seconds since Midnight, Jan 1 1970 UTC, ignoring leap seconds.
def asDatetime(self, tzinfo=None):

Return this time as an aware datetime.datetime instance.

The returned datetime object has the specified tzinfo, or a tzinfo describing UTC if the tzinfo parameter is None.
def asNaiveDatetime(self, tzinfo=None):

Return this time as a naive datetime.datetime instance.

The returned datetime object has its tzinfo set to None, but is in the timezone given by the tzinfo parameter, or UTC if the parameter is None.
def asRFC2822(self, tzinfo=None, includeDayOfWeek=True):

Return this Time formatted as specified in RFC 2822.

RFC 2822 specifies the format of email messages.

RFC 2822 says times in email addresses should reflect the local timezone. If tzinfo is a datetime.tzinfo instance, the returned formatted string will reflect that timezone. Otherwise, the timezone will be '-0000', which RFC 2822 defines as UTC, but with an unknown local timezone.

RFC 2822 states that the weekday is optional. The parameter includeDayOfWeek indicates whether or not to include it.
def asISO8601TimeAndDate(self, includeDelimiters=True, tzinfo=None, includeTimezone=True):

Return this time formatted as specified by ISO 8861.

ISO 8601 allows optional dashes to delimit dates and colons to delimit times. The parameter includeDelimiters (default True) defines the inclusion of these delimiters in the output.

If tzinfo is a datetime.tzinfo instance, the output time will be in the timezone given. If it is None (the default), then the timezone string will not be included in the output, and the time will be in UTC.

The includeTimezone parameter coresponds to the inclusion of an explicit timezone. The default is True.
def asStructTime(self, tzinfo=None):

Return this time represented as a time.struct_time.

tzinfo is a datetime.tzinfo instance coresponding to the desired timezone of the output. If is is the default None, UTC is assumed.
def asHumanly(self, tzinfo=None, now=None):

Return this time as a short string, tailored to the current time.

Parts of the date that can be assumed are omitted. Consequently, the output string depends on the current time. This is the format used for displaying dates in most user visible places in the quotient web UI.

By default, the current time is determined by the system clock. The current time used for formatting the time can be changed by providing a Time instance as the parameter 'now'.
def getBounds(self, tzinfo=None):
Return a pair describing the bounds of self.

This returns a pair (min, max) of Time instances. It is not quite the
same as (self, self + self.resolution). This is because timezones are
insignificant for instances with a resolution greater or equal to 1
day.

To illustrate the problem, consider a Time instance:

    T = Time.fromHumanly('today', tzinfo=anything)

This will return an equivalent instance independent of the tzinfo used.
The hour, minute, and second of this instance are 0, and its resolution
is one day.

Now say we have a sorted list of times, and we want to get all times
for 'today', where whoever said 'today' is in a timezone that's 5 hours
ahead of UTC. The start of 'today' in this timezone is UTC 05:00. The
example instance T above is before this, but obviously it is today.

The min and max times this returns are such that all potentially
matching instances are within this range. However, this range might
contain unmatching instances.

As an example of this, if 'today' is April first 2005, then
Time.fromISO8601TimeAndDate('2005-04-01T00:00:00') sorts in the same
place as T from above, but is not in the UTC+5 'today'.

TIME IS FUN!
def oneDay(self):

Return a Time instance representing the day of the start of self.

The returned new instance will be set to midnight of the day containing the first instant of self in the specified timezone, and have a resolution of datetime.timedelta(days=1).
def isAllDay(self):
Return True iff this instance represents exactly all day.
def isTimezoneDependent(self):

Return True iff timezone is relevant for this instance.

Timezone is only relevent for instances with a resolution better than one day.
def __cmp__(self, other):
Undocumented
def __eq__(self, other):
Undocumented
def __ne__(self, other):
Undocumented
def __repr__(self):
Undocumented
def __contains__(self, other):
Test if another Time instance is entirely within the period addressed by this one.
def __add__(self, addend):
Undocumented
def __sub__(self, subtrahend):
Implement subtraction of an interval or another time from this one.
ParameterssubtrahendThe object to be subtracted from this one. (type: datetime.timedelta or Time )
ReturnsIf subtrahend is a datetime.timedelta, the result is a Time instance which is offset from this one by that amount. If subtrahend is a Time, the result is a datetime.timedelta instance which gives the difference between it and this Time instance. (type: datetime.timedelta or Time )
API Documentation for vodafone-mobile-connect-card-driver-for-linux, generated by pydoctor at 2008-01-10 13:06:31.