DS3231 based on Adafruit RTClib

Embed: (wiki syntax)

« Back to documentation index

TimeSpan Class Reference

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.
 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);.
 TimeSpan (const TimeSpan &copy)
 Copy constructor, make a new TimeSpan using an existing one.
int16_t days () const
 Number of days in the TimeSpan e.g. 4.
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.
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.
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.
int32_t totalseconds () const
 Total number of seconds in the TimeSpan, e.g. 358027.
TimeSpan operator+ (const TimeSpan &right)
 Add two TimeSpans.
TimeSpan operator- (const TimeSpan &right)
 Subtract a TimeSpan.

Protected Attributes

int32_t _seconds
 Actual TimeSpan value is stored as seconds.

Detailed Description

Timespan which can represent changes in time with seconds accuracy.

Definition at line 195 of file RTClib.h.


Constructor & Destructor Documentation

TimeSpan ( int32_t  seconds = 0 )

Create a new TimeSpan object in seconds.

Parameters:
secondsNumber of seconds

Definition at line 498 of file RTClib.cpp.

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

Definition at line 512 of file RTClib.cpp.

TimeSpan ( const TimeSpan copy )

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

Parameters:
copyThe TimeSpan to copy

Definition at line 522 of file RTClib.cpp.


Member Function Documentation

int16_t days (  ) const

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

Returns:
int16_t days

Definition at line 207 of file RTClib.h.

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.

Returns:
int8_t hours

Definition at line 217 of file RTClib.h.

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.

Returns:
int8_t minutes

Definition at line 227 of file RTClib.h.

TimeSpan operator+ ( const TimeSpan right )

Add two TimeSpans.

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

Definition at line 533 of file RTClib.cpp.

TimeSpan operator- ( const TimeSpan right )

Subtract a TimeSpan.

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

Definition at line 545 of file RTClib.cpp.

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.

Returns:
int8_t seconds

Definition at line 237 of file RTClib.h.

int32_t totalseconds (  ) const

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

Returns:
int32_t seconds

Definition at line 245 of file RTClib.h.


Field Documentation

int32_t _seconds [protected]

Actual TimeSpan value is stored as seconds.

Definition at line 254 of file RTClib.h.