Duration

class aws_cdk.core.Duration

Bases: object

Represents a length of time.

The amount can be specified either as a literal value (e.g: 10) which cannot be negative, or as an unresolved number token.

Whent he amount is passed as an token, unit conversion is not possible.

Methods

to_days(*, integral=None)
Parameters
  • opts

  • integral (Optional[bool]) – If true, conversions into a larger time unit (e.g. Seconds to Mintues) will fail if the result is not an integer. Default: true

return :rtype: Union[int, float] :return: the value of this Duration expressed in Days.

to_hours(*, integral=None)
Parameters
  • opts

  • integral (Optional[bool]) – If true, conversions into a larger time unit (e.g. Seconds to Mintues) will fail if the result is not an integer. Default: true

return :rtype: Union[int, float] :return: the value of this Duration expressed in Hours.

to_iso_string()

return :rtype: str :return: an ISO 8601 representation of this period (see https://www.iso.org/fr/standard/70907.html).

to_milliseconds(*, integral=None)
Parameters
  • opts

  • integral (Optional[bool]) – If true, conversions into a larger time unit (e.g. Seconds to Mintues) will fail if the result is not an integer. Default: true

return :rtype: Union[int, float] :return: the value of this Duration expressed in Seconds.

to_minutes(*, integral=None)
Parameters
  • opts

  • integral (Optional[bool]) – If true, conversions into a larger time unit (e.g. Seconds to Mintues) will fail if the result is not an integer. Default: true

return :rtype: Union[int, float] :return: the value of this Duration expressed in Minutes.

to_seconds(*, integral=None)
Parameters
  • opts

  • integral (Optional[bool]) – If true, conversions into a larger time unit (e.g. Seconds to Mintues) will fail if the result is not an integer. Default: true

return :rtype: Union[int, float] :return: the value of this Duration expressed in Seconds.

to_string()

Returns a string representation of this Duration that is also a Token that cannot be successfully resolved.

This protects users against inadvertently stringifying a Duration object, when they should have called one of the to* methods instead.

Return type

str

Static Methods

classmethod days(amount)
Parameters

amount (Union[int, float]) – the amount of Days the Duration will represent.

return :rtype: Duration :return: a new Duration representing amount Days.

classmethod hours(amount)
Parameters

amount (Union[int, float]) – the amount of Hours the Duration will represent.

return :rtype: Duration :return: a new Duration representing amount Hours.

classmethod millis(amount)
Parameters

amount (Union[int, float]) – the amount of Milliseconds the Duration will represent.

return :rtype: Duration :return: a new Duration representing amount ms.

classmethod minutes(amount)
Parameters

amount (Union[int, float]) – the amount of Minutes the Duration will represent.

return :rtype: Duration :return: a new Duration representing amount Minutes.

classmethod parse(duration)

Parse a period formatted according to the ISO 8601 standard (see https://www.iso.org/fr/standard/70907.html).

Parameters

duration (str) – an ISO-formtted duration to be parsed.

return :rtype: Duration :return: the parsed Duration.

classmethod seconds(amount)
Parameters

amount (Union[int, float]) – the amount of Seconds the Duration will represent.

return :rtype: Duration :return: a new Duration representing amount Seconds.