You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
4.1 KiB

//#############################################################################################################################################################################################################
#include "IdiBusDateTime.h"
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
IdiDateFormat::IdiDateFormat(uint8_t day, uint8_t month, uint8_t century, uint8_t year99)
{
this->Day = day;
this->Month = month;
this->Century = century;
this->Year99 = year99;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
uint8_t IdiDateFormat::isValid(void)
{
if ( (this->Day == 0) || (this->Day > 31) ||
(this->Month == 0) || (this->Month > 12) ||
(this->Century > 99) || (this->Year99 > 99) ) { return 0; }
return 1;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
uint8_t IdiDateFormat::getSize(void) { return IDIDATE_FORMAT_LENGTH; }
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void IdiDateFormat::getBufForMMES(uint8_t *Data)
{
Data[IDIDATE_FORMAT_DAY_Pos] = this->Day;
Data[IDIDATE_FORMAT_MONTH_Pos] = this->Month;
Data[IDIDATE_FORMAT_CENTURY_Pos] = this->Century;
Data[IDIDATE_FORMAT_YEAR99_Pos] = this->Year99;
}
//=============================================================================================================================================================================================================
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//=============================================================================================================================================================================================================
IdiTimeFormat::IdiTimeFormat(uint8_t seconds, uint8_t minutes, uint8_t hours, int8_t timezone)
{
this->Seconds = seconds;
this->Minutes = minutes;
this->Hours = hours;
this->TimeZone = timezone;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
uint8_t IdiTimeFormat::isValid(void)
{
if ( (this->Seconds > 60) || (this->Minutes > 60) || (this->Hours > 23) ||
(this->TimeZone < IDITIME_FORMAT_TIMEZONE_MIN) || (this->TimeZone > IDITIME_FORMAT_TIMEZONE_MAX) ) { return 0; }
return 1;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
uint8_t IdiTimeFormat::getSize(void) { return IDITIME_FORMAT_LENGTH; }
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void IdiTimeFormat::getBufForMMES(uint8_t *Data)
{
Data[IDITIME_FORMAT_SECONDS_Pos] = this->Seconds;
Data[IDITIME_FORMAT_MINUTES_Pos] = this->Minutes;
Data[IDITIME_FORMAT_HOURS_Pos] = this->Hours;
Data[IDITIME_FORMAT_TIMEZONE_Pos] = (uint8_t)this->TimeZone;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//#############################################################################################################################################################################################################