- DateTimeCore:
- Added new functions Get/SetDateTime() for combined date & time get/set
- Added LocalTime param to ReadDate/Time() and BuildDate/TimeStr()
- Allow input time to interpretted as ether UTC or local time
- DeviceCore:
- Added SourceRef to HandleCommand()
54 lines
2.7 KiB
C
54 lines
2.7 KiB
C
/*
|
|
* DateTimeCore.h
|
|
*
|
|
* Created on: 3 Mar 2017
|
|
* Author: wentzelc
|
|
*/
|
|
|
|
#ifndef REDACORE_DATETIMECORE_H_
|
|
#define REDACORE_DATETIMECORE_H_
|
|
|
|
// Standard C/C++ Libraries
|
|
#include <cstdlib>
|
|
|
|
// redA Libraries
|
|
/* none */
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Get and set System Date and Time
|
|
bool GetTime( unsigned char &Hours, unsigned char &Minutes, unsigned char &Seconds );
|
|
bool GetDate( unsigned char &Day, unsigned char &Month, unsigned &Year );
|
|
bool GetDateTime( unsigned char &Day, unsigned char &Month, unsigned &Year,
|
|
unsigned char &Hours, unsigned char &Minutes, unsigned char &Seconds );
|
|
|
|
bool SetTime( unsigned char Hours, unsigned char Minutes, unsigned char Seconds );
|
|
bool SetDate( unsigned char Day, unsigned char Month, unsigned Year );
|
|
bool SetDateTime( unsigned char Day, unsigned char Month, unsigned Year,
|
|
unsigned char Hours, unsigned char Minutes, unsigned char Seconds );
|
|
|
|
char const * GetDateStr( const char * DateSeparator = "/" );
|
|
char const * GetTimeStr( const char * TimeSeparator = ":" );
|
|
char const * GetDateTimeStr( const char * DateSeparator = "/", const char * TimeSeparator = ":" );
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Build or interpret time data
|
|
bool ReadTime( const time_t EpochTime, bool LocalTime, unsigned char &Hours, unsigned char &Minutes, unsigned char &Seconds );
|
|
bool ReadDate( const time_t EpochTime, bool LocalTime, unsigned char &Day, unsigned char &Month, unsigned &Year );
|
|
bool ReadDateTime( const time_t EpochTime, bool LocalTime, unsigned char &Day, unsigned char &Month, unsigned &Year,
|
|
unsigned char &Hours, unsigned char &Minutes, unsigned char &Seconds );
|
|
|
|
bool ReadTimeStr( const char *DateTimeStr, unsigned char &Hours, unsigned char &Minutes, unsigned char &Seconds, bool Maxtime );
|
|
bool ReadDateStr( const char *DateTimeStr, unsigned char &Day, unsigned char &Month, unsigned &Year );
|
|
bool ReadDateTimeStr( const char *DateTimeStr, unsigned char &Day, unsigned char &Month, unsigned &Year,
|
|
unsigned char &Hours, unsigned char &Minutes, unsigned char &Seconds, bool Maxtime );
|
|
|
|
char const * BuildDateStr( const time_t EpochTime, bool LocalTime, const char * DateSeparator = "/" );
|
|
char const * BuildTimeStr( const time_t EpochTime, bool LocalTime, const char * TimeSeparator = ":" );
|
|
char const * BuildDateTimeStr( const time_t EpochTime, bool LocalTime, const char * DateSeparator = "/", const char * TimeSeparator = ":" );
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
#endif /* REDACORE_DATETIMECORE_H_ */
|