Wrong date! Bad month!!!

 

Hi! I was trying to use the datetime feature to know the day of the week  but I kept getting "Sunday", yet it's a Thursday. 

I developed this code to check the problem in the code. Run this and see

//---
#include <Tools\DateTime.mqh>
CDateTime time;
//...
int OnInit()
{
   Print("Day: ", time.MonthName());
//...
   return(INIT_FAILED);
}

It prints bad month. Using:

//---
#include <Tools\DateTime.mqh>
CDateTime time;
//...
int OnInit()
{
   Print("Day: ", time.DayName());
//...
   return(INIT_FAILED);
}

...prints wrong day. where is the problem really? I'm lost.

 

You have created the CDatetime object "time" but you didn't set a value to it.

It prints "Sunday" because it returns 0.

time.DateTime(TimeCurrent());
Print("Day: ", time.DayName());
 
I couldn't figure out a way to set a value to it dynamically when the function is called. Had to think of another way.
Reason: