TSDuck v3.46-4930
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches

#include <tsISOTime.h>

Public Types

enum  TimeType {
  NONE = 0x00 ,
  TIME = 0x01 ,
  DURATION = 0x02 ,
  START_END = 0x04 ,
  START_DURATION = 0x08 ,
  DURATION_END = 0x10 ,
  RECURRING = 0x20 ,
  ANY_INTERVAL = 0x1E ,
  ANY = 0x3F
}

Public Member Functions

 ISOTime ()=default
template<class Rep, class Period>
 ISOTime (cn::duration< Rep, Period > duration, const Time &end, size_t recurrences=0)
template<class Rep, class Period>
 ISOTime (cn::duration< Rep, Period > duration, size_t recurrences=0)
template<class Rep, class Period>
 ISOTime (const Time &start, cn::duration< Rep, Period > duration, size_t recurrences=0)
 ISOTime (const Time &start, const Time &end, size_t recurrences=0)
 ISOTime (const Time &time)
 ISOTime (const UString &str)
void clear ()
cn::milliseconds duration () const
Time end () const
bool fromString (const UString &str)
bool isInterval () const
bool isRecurring () const
bool isSingleTime () const
bool isUnbounded () const
bool isValid () const
 operator Time () const
size_t recurrences () const
Time start () const
UString toString (TimeType format=NONE) const
TimeType type () const

Static Public Member Functions

static cn::milliseconds DurationFromISO (const UString &str)
static Time TimeFromISO (const UString &str)
template<class Rep, class Period>
static UString ToISO (cn::duration< Rep, Period > duration)
static UString ToISO (const Time &time)
template<class Rep, class Period>
static UString ToISO (const Time &time, cn::duration< Rep, Period > utc_offset)

Static Public Attributes

static constexpr size_t UNBOUNDED_RECURRENCES = std::numeric_limits<size_t>::max()

Detailed Description

The ISOTime class convert dates, times, and durations with ISO 8601 representation.

Member Enumeration Documentation

◆ TimeType

Type of time data which can be represented in ISO 8601.

Enumerator
NONE 

No data, invalid object.

TIME 

One date & time value.

DURATION 

A duration not associated with any start or end.

START_END 

A start and an end.

START_DURATION 

A start and a duration.

DURATION_END 

A duration and an end.

RECURRING 

Additional flag: recurring time interval.

ANY_INTERVAL 

A bit mask of all time-interval formats (non-recurring).

ANY 

A bit mask of all possible formats.

Constructor & Destructor Documentation

◆ ISOTime() [1/7]

ts::ISOTime::ISOTime ( )
default

Default constructor.

◆ ISOTime() [2/7]

ts::ISOTime::ISOTime ( const UString & str)
inline

Constructor from a string in ISO 8601 format.

Parameters
[in]strA string in ISO 8601 format.

◆ ISOTime() [3/7]

ts::ISOTime::ISOTime ( const Time & time)
inline

Constructor using one date & time value.

Parameters
[in]timeThe date & time to set.

◆ ISOTime() [4/7]

template<class Rep, class Period>
ts::ISOTime::ISOTime ( cn::duration< Rep, Period > duration,
size_t recurrences = 0 )
inline

Constructor using a duration not associated with any start or end.

Parameters
[in]durationTime interval duration.
[in]recurrencesIf non-zero, the time-interval is recurring, with that number of recurrences.

◆ ISOTime() [5/7]

ts::ISOTime::ISOTime ( const Time & start,
const Time & end,
size_t recurrences = 0 )
inline

Constructor using a start and end date.

Parameters
[in]startInterval start time.
[in]endInterval end time.
[in]recurrencesIf non-zero, the time-interval is recurring, with that number of recurrences.

◆ ISOTime() [6/7]

template<class Rep, class Period>
ts::ISOTime::ISOTime ( const Time & start,
cn::duration< Rep, Period > duration,
size_t recurrences = 0 )
inline

Constructor using a start and a duration.

Parameters
[in]startInterval start time.
[in]durationTime interval duration.
[in]recurrencesIf non-zero, the time-interval is recurring, with that number of recurrences.

◆ ISOTime() [7/7]

template<class Rep, class Period>
ts::ISOTime::ISOTime ( cn::duration< Rep, Period > duration,
const Time & end,
size_t recurrences = 0 )
inline

Constructor using a duration and an end.

Parameters
[in]durationTime interval duration.
[in]endInterval end time.
[in]recurrencesIf non-zero, the time-interval is recurring, with that number of recurrences.

Member Function Documentation

◆ clear()

void ts::ISOTime::clear ( )

Reset the content of the object to an invalid state.

◆ isValid()

bool ts::ISOTime::isValid ( ) const
inline

Check if this object contains a valid value.

Returns
True if this object contains a valid value, false otherwise.

◆ isSingleTime()

bool ts::ISOTime::isSingleTime ( ) const
inline

Check if this object contains a single date & time value.

Returns
True if this object contains a single date & time value, false otherwise.

◆ isInterval()

bool ts::ISOTime::isInterval ( ) const
inline

Check if this object contains a time interval (recurring or not).

Returns
True if this object contains a time interval, false otherwise.

◆ isRecurring()

bool ts::ISOTime::isRecurring ( ) const
inline

Check if this object contains a recurring interval.

Returns
True if this object contains a recurring interval, false otherwise.

◆ isUnbounded()

bool ts::ISOTime::isUnbounded ( ) const
inline

Check if this object contains an unbounded recurring interval.

Returns
True if this object contains an unbounded recurring interval, false otherwise.

◆ type()

TimeType ts::ISOTime::type ( ) const
inline

Get the type of ISO 8601 time data.

Returns
The type of ISO 8601 time data.

◆ toString()

UString ts::ISOTime::toString ( TimeType format = NONE) const

Format this object as a ISO 8601 string.

Parameters
[in]formatRequired format. In NONE, use the default format for that object.
Returns
The corresponding ISO 8601 string.

◆ fromString()

bool ts::ISOTime::fromString ( const UString & str)

Set the value of this object from a string in ISO 8601 format.

Parameters
[in]strA string in ISO 8601 format.
Returns
True on success, false on error (the object is then invalid).

◆ operator Time()

ts::ISOTime::operator Time ( ) const
inline

Conversion to a Time value.

Returns
The single date and time or the start date for a time interval. Return ts::Time::Epoch on error.

◆ start()

Time ts::ISOTime::start ( ) const

Get the time interval start time.

Returns
The start date for a time interval or single date and time. Return ts::Time::Epoch on error.

◆ end()

Time ts::ISOTime::end ( ) const

Get the time interval end time.

Returns
The end date for a time interval or single date and time. Return ts::Time::Epoch on error.

◆ duration()

cn::milliseconds ts::ISOTime::duration ( ) const

Get the duration of the time interval.

Returns
The duration of the time interval, zero otherwise.

◆ recurrences()

size_t ts::ISOTime::recurrences ( ) const
inline

Get the number of recurrences of the time interval.

Returns
The number of recurrences of the time interval for a recurring interval, zero otherwise.

◆ TimeFromISO()

Time ts::ISOTime::TimeFromISO ( const UString & str)
static

Decode a time from an ISO 8601 representation. Missing date fields default to the current UTC time. Missing time fields default to zero. The mpeg7:timePointType format is an extension of ISO 8601 and is also recognized here.

Parameters
[in]strA string describing a date and time in ISO 8601 representation.
Returns
The converted time or ts::Time::Epoch if the string cannot be decoded.

◆ DurationFromISO()

cn::milliseconds ts::ISOTime::DurationFromISO ( const UString & str)
static

Decode a duration from an ISO 8601 representation.

Parameters
[in]strA string describing a duration in ISO 8601 representation.
Returns
The converted duration in milliseconds or a negative value if the string cannot be decoded.

◆ ToISO() [1/3]

UString ts::ISOTime::ToISO ( const Time & time)
inlinestatic

Format a time in ISO 8601 representation.

Parameters
[in]timeThe date and time to format.
Returns
A string describing the date and time in ISO 8601 representation.

◆ ToISO() [2/3]

template<class Rep, class Period>
UString ts::ISOTime::ToISO ( const Time & time,
cn::duration< Rep, Period > utc_offset )
inlinestatic

Format a time in ISO 8601 representation, including an offset from UTC time.

Parameters
[in]timeThe date and time to format.
[in]utc_offsetThe offset from UTC time to include in the representation.
Returns
A string describing the date and time in ISO 8601 representation.

◆ ToISO() [3/3]

template<class Rep, class Period>
UString ts::ISOTime::ToISO ( cn::duration< Rep, Period > duration)
inlinestatic

Format a duration in ISO 8601 representation.

Parameters
[in]durationTime interval duration.
Returns
A string describing the duration in ISO 8601 representation.

Member Data Documentation

◆ UNBOUNDED_RECURRENCES

size_t ts::ISOTime::UNBOUNDED_RECURRENCES = std::numeric_limits<size_t>::max()
staticconstexpr

Number of time-interval recurrences meaning "unbounded".


The documentation for this class was generated from the following file: