result time_day_of_year of TimeToStruct() and TimeDayOfYear() is different

 
#property strict

int OnInit()
{
MqlDateTime _Time;
TimeToStruct(TimeCurrent(),_Time);
Print("_Time.day_of_year = "+_Time.day_of_year);
Print("TimeDayOfYear(TimeCurrent()) = "+TimeDayOfYear(TimeCurrent()));
return(INIT_SUCCEEDED);
}


It's should same value ? I also tested with the function TimeCurrent(Time) also gives the same results as the function TimeToStruct().

This therefore raises the question, which result is correct? But no matter what, both of these functions should produce the same day_of_year results.

 

I try calculate by me self with this formula (In code)

#property strict

int OnInit()
{
MqlDateTime _Time;
TimeToStruct(TimeCurrent(),_Time);
Print("_Time.day_of_year = "+_Time.day_of_year);
Print("TimeDayOfYear(TimeCurrent()) = "+TimeDayOfYear(TimeCurrent()));
Print("My calculate = "+double(((double)TimeCurrent()-(double)StringToTime("01.01.2024"))/(1440.0*60.0)));
return(INIT_SUCCEEDED);
}

The result is 108.6861921296296 So the correct value is 108 days. So the function TimeDayOfYear() is incorrect calculate.


Please send this error to the Metaqutes developer. Thank you.

 

https://www.mql5.com/en/docs/constants/structures/mqldatetime

struct MqlDateTime
  {
   int year;           // Year
   int mon;            // Month
   int day;            // Day
   int hour;           // Hour
   int min;            // Minutes
   int sec;            // Seconds
   int day_of_week;    // Day of week (0-Sunday, 1-Monday, ... ,6-Saturday)
   int day_of_year;    // Day number of the year (January 1st is assigned the number value of zero)
  };


https://docs.mql4.com/dateandtime/timedayofyear

TimeDayOfYear

Returned value

Day (1 means 1 January,..,365(6) does 31 December) of year of the specified date.

 

These are outdated functions (highlighted with a red rectangle in the screenshot), do not use outdated functions.


 
Okay, are there any other functions that have outdated?
 
momocoong #:
Okay, are there any other functions that have outdated?

Let me remind you that MT4 is no longer being developed. Of course, there are other outdated features in MT4. But I don't think anyone can give you an exhaustive list of them.

The first thing that comes to my mind is that all 'iXXXOnArray' are broken (and no one will fix them). I can't remember anything else offhand.

 
Vladislav Boyko #:
I can't remember anything else offhand.

AccountFreeMarginCheck may not work correctly, if I'm not mistaken. I abandoned it a long time ago, as far as I remember, because it did not work correctly.

Vladislav Boyko #:
But I don't think anyone can give you an exhaustive list of them.

Usually, a person remembers what he uses, and not what he abandoned.

 
Oh, this made me have to go back and double check all my MQL4 code to make sure it was working properly. Thank you so much!