DayOfWeek in RTC library for R4 WIFI

I am playing with built-in RTC module in R4WIFI. The RTC library provides following methods:

getDayOfMonth()
getMonth()
getYear()
getHour()
getMinutes()
getSeconds()
The RTCTime object contains DayOfWeek and yet there is no method

getDayOfWeek()

Has anyone figured out how to extract that information after executing
RTCTime currentTime;
RTC.getTime(currentTime);
From the currentTime RTCTime object?

Which is the RTC library? Show the link
There are dozens RTC libraries in the github

under the assumption your object is named obj it could be

int dayOfWeek = obj.getDayOfWeek();

if not:

  • show your code
  • show the error message you get
  • LINK to the EXACT location of the used library
int currentSecond;

void setup() {  
  Serial.begin(9600);  
  RTC.begin();    
  RTCTime startTime(17, Month::SEPTEMBER, 2023, 13, 37, 00, 
                    DayOfWeek::SUNDAY, SaveLight::SAVING_TIME_ACTIVE); 
  RTC.setTime(startTime);
}

void loop(){
  RTCTime currentTime;
  RTC.getTime(currentTime);
  if (currentTime.getSeconds()!=currentSecond){
    //Serial.print(currentTime.getDayOfWeek()); Serial.print(" ");
    Serial.print(currentTime.getDayOfMonth()); Serial.print(".");
    Serial.print(Month2int(currentTime.getMonth())); Serial.print(".");
    Serial.print(currentTime.getYear()); Serial.print(" ");
    Serial.print(currentTime.getHour()); Serial.print(":");
    Serial.print(currentTime.getMinutes()); Serial.print(":");
    Serial.println(currentTime.getSeconds());
    currentSecond=currentTime.getSeconds();
  }

If I uncomment the line I get :
no matching function for call to 'UART::print(DayOfWeek)'

You still haven't said which library you're using.

That doesn't make sense!

Please copy & paste the full message.

C:\Users\Dell\Documents\ArduinoData\packages\arduino\hardware\renesas_uno\1.0.2\cores\arduino/api/String.h:70:2: note: no known conversion for argument 1 from 'DayOfWeek' to 'const char*'
exit status 1
no matching function for call to 'arduino::String::String(DayOfWeek)'

This does not mean that getDayOfWeek() is undefined, it means that print() does not know how to display the value it returns, which is of type

enum class DayOfWeek : uint8_t {
    MONDAY = 1,
    TUESDAY = 2, 
...

https://github.com/arduino/ArduinoCore-renesas/blob/1.0.4/libraries/RTC/src/RTC.h#L48-L58

This will convert it to something that print() can handle:

int DayOfWeek2int(DayOfWeek dow, bool sunday_first);

DayOfWeek is a bit like Month. for instance
DayOfWeek has possible values of:
DayOfWeek::MONDAY
DayOfWeek::TUESDAY etc
While Month has possible vaues of :
Month::JANUARY
Month::FEBRUARY etc.
In the example that comes with library they show how to display the month in dec format:
Serial.print(Month2int(currentTime.getMonth()));
I cannot find much on Month2Int method. Without it I get the same error like for DayOfWeek

That is great. Thanks. Are there methods to convert either DayOfWeek or Month to its string representation ather then to intiger value

If there aren't, a lookup table would probably be easiest ...

eg,

const char *daysOfTheWeek[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

from: