Files
redAcore/DateTimeCore.h
Charl Wentzel b5912123cc Minor update:
- Add separator between date/time for GetDateTimeStr()
2019-10-13 23:18:50 +02:00

63 lines
3.4 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 = ":", const char * Separator = " " );
//---------------------------------------------------------------------------
// 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 ReadDateTime( const char * DateTimeStr, bool LocalTime, time_t &EpochTime );
bool ReadTimeStr( const char *DateTimeStr, unsigned char &Hours, unsigned char &Minutes, unsigned char &Seconds, bool Maxtime = false );
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 = false );
char const * BuildDateStr( unsigned char Day, unsigned char Month, unsigned Year, const char * DateSeparator = "/" );
char const * BuildTimeStr( unsigned char Hours, unsigned char Minutes, unsigned char Seconds, const char * TimeSeparator = ":" );
char const * BuildDateTimeStr( unsigned char Day, unsigned char Month, unsigned Year,
unsigned char Hours, unsigned char Minutes, unsigned char Seconds,
const char * DateSeparator = "/", const char * TimeSeparator = ":", const char * Separator = " " );
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 = ":", const char * Separator = " " );
//---------------------------------------------------------------------------
#endif /* REDACORE_DATETIMECORE_H_ */