Defines the time Context that constructs unit types and manages their relationships to other unit types.
collections
fractions0
functools0
operator0
builtins0
Type
Sequence0
abstract0
kinds0
kinds = (
'definite',
'indefinite',
'subjective',
)
unix_epoch_delta0
unix_epoch_delta = (((((2000-1970) * 365) + 7) * (24*60*60)) + (24*60*60))
Exception0
Generic time exception.
TransformException0
An attempt to transform units failed.
TransformExceptionunit_input
unit_input = None
TransformExceptionunit_output
unit_output = None
TransformExceptioncontext
context = None
TransformException__init__0
__init__(self, *args)
Inconceivable0
An attempt to represent a unit in like-terms was not possible given the current implementation.
Usually raised when a finite term attempts to convert an indefinite term or an ambiguous term.
FormatError0
ParseError0
The exception raised when a string representation of the datetime could not be parsed.
ParseError__init__0
__init__(self, source)
ParseError__str__10%
__str__(self)
StructureError0
The exception raised when the structure of a parsed format could not be transformed.
StructureError__init__0
__init__(self, source, struct)
StructureError__str__10%
__str__(self)
IntegrityError0
The exception raised when a parsed point in time is not consistent.
Notably, in the RFC format, there are portions specifying intersecting parts of a timestamp. (The day of week field is arguably superfluous.)
IntegrityError__init__0
__init__(self, source, struct, tuple)
IntegrityError__str__10%
__str__(self)
Unit0
The base class for finite abstract.Measure and abstract.Point subclasses across all Context instances.
Unit__slots__0
__slots__ = ()
@classmethod
Unitconstruct197%
construct(Class, units, parts)
Unitof0
of(Class, *units, **parts)
Unitupdate0
update(self)
Unittruncate0
truncate(self, unit)
Unitselect0
select(self, part)
Measure
Measure__slots__0
__slots__ = ()
@property
Measurestart0
Measurestop10%
Measure__neg__10%
__neg__(self)
Measure__abs__10%
__abs__(self)
Measure__str__0
__str__(self)
Measure__repr__140%
__repr__(self)
Measure__contains__10%
__contains__(self, t)
Measureelapse10%
elapse(self, *args, **parts)
Measureadjust0
adjust = elapse
Measureincrease10%
increase(self, *units, **parts)
Measuredecrease0
decrease(self, *units, **parts)
Point
Point__slots__0
__slots__ = ()
@property
Pointstart10%
Pointstop10%
Point__contains__0
__contains__(self, t)
Point__str__10%
__str__(self)
Point__repr__10%
__repr__(self)
Pointrollback0
rollback(self, *units, **parts)
Pointelapse0
elapse(self, *units, **parts)
Pointmeasure0
measure(self, pit)
Pointleads466%
leads(self, pit)
Pointprecedes0
precedes = leads
Pointfollows283%
follows(self, pit)
Pointproceeds0
proceeds = follows
Context0
A container for time units and transformations.
Context__init__0
__init__(self)
Contextdeclare188%
declare(self, id, datum)
Declare a fundamental unit for use in a context.
All defined, Context.define, units are defined in terms of a declared unit.
Contextdefine183%
define(self, id, term, exponent)
Defines a Unit in terms of another unit.
Contextbridge0
bridge(self, from_unit, to_unit, transformer)
Assign a "bridge" between two units.
In the case where a unit cannot not be resolved from its definitions, bridges can be used to perform the conversion.
Contextcontainer166%
container(self, id, pack, unpack)
Contextconstant0
constant(self, id, value)
Contextcompose0
compose(self, from_unit, to_unit)
Compose two ratios into another so that the from_unit can be converted into the to_unit.
Ratio compositions are LRU cached.
Contextconvert284%
convert(self, from_unit, to_unit, value)
Contextregister_point_class0
register_point_class(self, Point)
Contextregister_measure_class0
register_measure_class(self, Measure)
Contextnew_measure_class0
new_measure_class(self, id)
Contextnew_point_class0
new_point_class(self, Measure)
Contextdatum_for_point180%
datum_for_point(self, to_unit)
Contextpoint_from_unit40%
point_from_unit(self, unit)
Contextmeasure_from_unit0
measure_from_unit(self, unit)
Contextrepresent0
represent(self, term, unitseq)
Contextpoint_factory0Type[abstract.Point]
point_factory(self, Measure, qname)
Construct a Point class from the given scalar.
Contextmeasure_factory0Type[abstract.Measure]
measure_factory(self, id, qname)
Construct a measure with the designated unit identifier and class.
standard_context294%tuple[Context, Sequence[abstract.Measure], Sequence[abstract.Point]]
standard_context(qname)
Construct the standard time context from the local modules.
Normally called by types during import to initialize the primary data types.