RTClib
Public Member Functions | Protected Attributes | List of all members
TimeSpan Class Reference

Timespan which can represent changes in time with seconds accuracy. More...

#include <RTClib.h>

Public Member Functions

 TimeSpan (int32_t seconds=0)
 Create a new TimeSpan object in seconds. More...
 
 TimeSpan (int16_t days, int8_t hours, int8_t minutes, int8_t seconds)
 Create a new TimeSpan object using a number of days/hours/minutes/seconds e.g. Make a TimeSpan of 3 hours and 45 minutes: new TimeSpan(0, 3, 45, 0);. More...
 
 TimeSpan (const TimeSpan &copy)
 Copy constructor, make a new TimeSpan using an existing one. More...
 
int16_t days () const
 Number of days in the TimeSpan e.g. 4. More...
 
int8_t hours () const
 Number of hours in the TimeSpan This is not the total hours, it includes the days e.g. 4 days, 3 hours - NOT 99 hours. More...
 
int8_t minutes () const
 Number of minutes in the TimeSpan This is not the total minutes, it includes days/hours e.g. 4 days, 3 hours, 27 minutes. More...
 
int8_t seconds () const
 Number of seconds in the TimeSpan This is not the total seconds, it includes the days/hours/minutes e.g. 4 days, 3 hours, 27 minutes, 7 seconds. More...
 
int32_t totalseconds () const
 Total number of seconds in the TimeSpan, e.g. 358027. More...
 
TimeSpan operator+ (const TimeSpan &right)
 Add two TimeSpans. More...
 
TimeSpan operator- (const TimeSpan &right)
 Subtract a TimeSpan. More...
 

Protected Attributes

int32_t _seconds
 Actual TimeSpan value is stored as seconds.
 

Detailed Description

Timespan which can represent changes in time with seconds accuracy.

Constructor & Destructor Documentation

◆ TimeSpan() [1/3]

TimeSpan::TimeSpan ( int32_t  seconds = 0)

Create a new TimeSpan object in seconds.

Parameters
secondsNumber of seconds

◆ TimeSpan() [2/3]

TimeSpan::TimeSpan ( int16_t  days,
int8_t  hours,
int8_t  minutes,
int8_t  seconds 
)

Create a new TimeSpan object using a number of days/hours/minutes/seconds e.g. Make a TimeSpan of 3 hours and 45 minutes: new TimeSpan(0, 3, 45, 0);.

Parameters
daysNumber of days
hoursNumber of hours
minutesNumber of minutes
secondsNumber of seconds

◆ TimeSpan() [3/3]

TimeSpan::TimeSpan ( const TimeSpan copy)

Copy constructor, make a new TimeSpan using an existing one.

Parameters
copyThe TimeSpan to copy

Member Function Documentation

◆ days()

int16_t TimeSpan::days ( ) const
inline

Number of days in the TimeSpan e.g. 4.

Returns
int16_t days

◆ hours()

int8_t TimeSpan::hours ( ) const
inline

Number of hours in the TimeSpan This is not the total hours, it includes the days e.g. 4 days, 3 hours - NOT 99 hours.

Returns
int8_t hours

◆ minutes()

int8_t TimeSpan::minutes ( ) const
inline

Number of minutes in the TimeSpan This is not the total minutes, it includes days/hours e.g. 4 days, 3 hours, 27 minutes.

Returns
int8_t minutes

◆ seconds()

int8_t TimeSpan::seconds ( ) const
inline

Number of seconds in the TimeSpan This is not the total seconds, it includes the days/hours/minutes e.g. 4 days, 3 hours, 27 minutes, 7 seconds.

Returns
int8_t seconds

◆ totalseconds()

int32_t TimeSpan::totalseconds ( ) const
inline

Total number of seconds in the TimeSpan, e.g. 358027.

Returns
int32_t seconds

◆ operator+()

TimeSpan TimeSpan::operator+ ( const TimeSpan right)

Add two TimeSpans.

Parameters
rightTimeSpan to add
Returns
New TimeSpan object, sum of left and right

◆ operator-()

TimeSpan TimeSpan::operator- ( const TimeSpan right)

Subtract a TimeSpan.

Parameters
rightTimeSpan to subtract
Returns
New TimeSpan object, right subtracted from left

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