Datetime Helpers
Helpers for datetime
.
- class proto.datetime_helpers.DatetimeWithNanoseconds(*args, **kw)[source]
Track nanosecond in addition to normal datetime attrs.
Nanosecond can be passed only as a keyword argument.
- classmethod from_rfc3339(stamp)[source]
Parse RFC3339-compliant timestamp, preserving nanoseconds.
- Parameters
stamp (str) – RFC3339 stamp, with up to nanosecond precision
- Returns
an instance matching the timestamp string
- Return type
- Raises
ValueError – if stamp does not match the expected format
- classmethod from_timestamp_pb(stamp)[source]
Parse RFC3339-compliant timestamp, preserving nanoseconds.
- Parameters
stamp (
Timestamp
) – timestamp message- Returns
an instance matching the timestamp message
- Return type
- property nanosecond
nanosecond precision.
- Type
Read-only
- replace(*args, **kw)[source]
Return a date with the same value, except for those parameters given new values by whichever keyword arguments are specified. For example, if d == date(2002, 12, 31), then d.replace(day=26) == date(2002, 12, 26). NOTE: nanosecond and microsecond are mutually exclusive arguments.