Duration¶
-
class
aws_cdk.core.
Duration
(*args, **kwargs)¶ 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.When the amount is passed as a token, unit conversion is not possible.
Methods
-
to_days
(*, integral=None)¶ Return the total number of days in this Duration.
- Parameters
integral (
Optional
[bool
]) – Iftrue
, conversions into a larger time unit (e.g.Seconds
toMinutes
) will fail if the result is not an integer. Default: true- Return type
Union
[int
,float
]- Returns
the value of this
Duration
expressed in Days.
-
to_hours
(*, integral=None)¶ Return the total number of hours in this Duration.
- Parameters
integral (
Optional
[bool
]) – Iftrue
, conversions into a larger time unit (e.g.Seconds
toMinutes
) will fail if the result is not an integer. Default: true- Return type
Union
[int
,float
]- Returns
the value of this
Duration
expressed in Hours.
-
to_human_string
()¶ Turn this duration into a human-readable string.
- Return type
str
-
to_iso_string
()¶ (deprecated) Return an ISO 8601 representation of this period.
- Return type
str
- Returns
a string starting with ‘P’ describing the period
- Deprecated
Use
toIsoString()
instead.- See
- Stability
deprecated
-
to_milliseconds
(*, integral=None)¶ Return the total number of milliseconds in this Duration.
- Parameters
integral (
Optional
[bool
]) – Iftrue
, conversions into a larger time unit (e.g.Seconds
toMinutes
) will fail if the result is not an integer. Default: true- Return type
Union
[int
,float
]- Returns
the value of this
Duration
expressed in Milliseconds.
-
to_minutes
(*, integral=None)¶ Return the total number of minutes in this Duration.
- Parameters
integral (
Optional
[bool
]) – Iftrue
, conversions into a larger time unit (e.g.Seconds
toMinutes
) will fail if the result is not an integer. Default: true- Return type
Union
[int
,float
]- Returns
the value of this
Duration
expressed in Minutes.
-
to_seconds
(*, integral=None)¶ Return the total number of seconds in this Duration.
- Parameters
integral (
Optional
[bool
]) – Iftrue
, conversions into a larger time unit (e.g.Seconds
toMinutes
) will fail if the result is not an integer. Default: true- Return type
Union
[int
,float
]- Returns
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 theto*
methods instead.- Return type
str
Static Methods
-
classmethod
days
(amount)¶ Create a Duration representing an amount of days.
- Parameters
amount (
Union
[int
,float
]) – the amount of Days theDuration
will represent.- Return type
- Returns
a new
Duration
representingamount
Days.
-
classmethod
hours
(amount)¶ Create a Duration representing an amount of hours.
- Parameters
amount (
Union
[int
,float
]) – the amount of Hours theDuration
will represent.- Return type
- Returns
a new
Duration
representingamount
Hours.
-
classmethod
millis
(amount)¶ Create a Duration representing an amount of milliseconds.
- Parameters
amount (
Union
[int
,float
]) – the amount of Milliseconds theDuration
will represent.- Return type
- Returns
a new
Duration
representingamount
ms.
-
classmethod
minutes
(amount)¶ Create a Duration representing an amount of minutes.
- Parameters
amount (
Union
[int
,float
]) – the amount of Minutes theDuration
will represent.- Return type
- Returns
a new
Duration
representingamount
Minutes.
-
classmethod
parse
(duration)¶ Parse a period formatted according to the ISO 8601 standard.
- Parameters
duration (
str
) – an ISO-formtted duration to be parsed.- Return type
- Returns
the parsed
Duration
.- See
-