apache_beam.utils.timestamp module

Timestamp utilities.

For internal use only; no backwards-compatibility guarantees.

class apache_beam.utils.timestamp.Timestamp(seconds=0, micros=0)[source]

Bases: object

Represents a Unix second timestamp with microsecond granularity.

Can be treated in common timestamp arithmetic operations as a numeric type.

Internally stores a time interval as an int of microseconds. This strategy is necessary since floating point values lose precision when storing values, especially after arithmetic operations (for example, 10000000 % 0.1 evaluates to 0.0999999994448885).

static of(seconds)[source]

Return the Timestamp for the given number of seconds.

If the input is already a Timestamp, the input itself will be returned.

Parameters:seconds – Number of seconds as int, float or Timestamp.
Returns:Corresponding Timestamp object.
predecessor()[source]

Returns the largest timestamp smaller than self.

to_utc_datetime()[source]
isoformat()[source]
class apache_beam.utils.timestamp.Duration(seconds=0, micros=0)[source]

Bases: object

Represents a second duration with microsecond granularity.

Can be treated in common arithmetic operations as a numeric type.

Internally stores a time interval as an int of microseconds. This strategy is necessary since floating point values lose precision when storing values, especially after arithmetic operations (for example, 10000000 % 0.1 evaluates to 0.0999999994448885).

static of(seconds)[source]

Return the Duration for the given number of seconds since Unix epoch.

If the input is already a Duration, the input itself will be returned.

Parameters:seconds – Number of seconds as int, float or Duration.
Returns:Corresponding Duration object.