34 lines
770 B
C++
34 lines
770 B
C++
#include "RtcManager.h"
|
|
|
|
RtcManager::RtcManager(RTC_DS3231 &rtc) : _rtcRef(rtc)
|
|
{
|
|
}
|
|
|
|
DateTime RtcManager::getDateTime() const
|
|
{
|
|
return _rtcRef.now();
|
|
}
|
|
|
|
void RtcManager::setDate(const DateTime dateTime)
|
|
{
|
|
DateTime timePart = _rtcRef.now();
|
|
_rtcRef.adjust(DateTime(dateTime.year(), dateTime.month(), dateTime.day(), timePart.hour(), timePart.minute(), timePart.second()));
|
|
}
|
|
|
|
void RtcManager::setTime(const DateTime dateTime)
|
|
{
|
|
DateTime datePart = _rtcRef.now();
|
|
_rtcRef.adjust(DateTime(datePart.year(), datePart.month(), datePart.day(), dateTime.hour(), dateTime.minute(), dateTime.second()));
|
|
}
|
|
|
|
void RtcManager::setDateTime(const DateTime dateTime)
|
|
{
|
|
_rtcRef.adjust(dateTime);
|
|
}
|
|
|
|
boolean RtcManager::hasLostPower() const
|
|
{
|
|
return _rtcRef.lostPower();
|
|
}
|
|
|