That's seems weird, are you sure it's the real code executed to produce this output ?
You haven't posted the code for when ExpiredDate1 becomes ExpiredDate (the "AFTER SPLIT" bit).
Substituting "2015-05-07" for GetExpireDateFromServer(tanggal, Your_Id) and ignoring the AFTER SPLIT (can't see the code), everything behaves as it should:
//string ExpiredDate1 = GetExpireDateFromServer(tanggal, Your_Id); string ExpiredDate = "2015-05-07"; PrintFormat("FROM SERVER : %s", ExpiredDate); PrintFormat("AFTER SPLIT : %s", ExpiredDate); StringReplace(ExpiredDate,"-","."); PrintFormat("AFTER REPLACE : %s", ExpiredDate); datetime d1=StrToTime(ExpiredDate); PrintFormat("Expire : %d - %s",d1, TimeToStr(d1,TIME_DATE|TIME_SECONDS)); datetime d2=TimeCurrent(); PrintFormat("Now : %d - %s",d2, TimeToStr(d2,TIME_DATE|TIME_SECONDS));
Thx for the replies.
Yes, if we hardcoded :
string ExpiredDate = "2015-05-07";
It will get the true value of date. But this value was get from external function :
string ExpiredDate1 = GetExpireDateFromServer(tanggal, Your_Id);
I only split : ExpiredDate1 to ExpiredDate and as we see the true value from server.
The complete codes are below :
if(clickedChartObject==DRAWUI_ACTIVATE || clickedChartObject==DRAWUI_ACTTITLE) { int year = TimeYear(iTime(Symbol(),0,0)); int month = TimeMonth(iTime(Symbol(),0,0)); int date = TimeDay(iTime(Symbol(),0,0)); if(year<=0) year=2000; if(month<=0) month=1; if(date<=0) date=1; string tanggal = "2014-1-1"; tanggal = year + "-" + month + "-" + date; string ExpiredDate1 = GetExpireDateFromServer(tanggal, Your_Id); PrintFormat("FROM SERVER : %s", ExpiredDate1); string sep=":"; ushort u_sep; string result[]; u_sep=StringGetCharacter(sep,0); int k=StringSplit(ExpiredDate1,u_sep,result); int size=ArraySize(result); string expired=""; if(size>1) { expired = result[0]; IsExpired = 1; ExpiredDate = result[1]; StringReplace(ExpiredDate,"-","."); ObjectSetString(0,DRAWUI_ACTTITLE,OBJPROP_TEXT,ExpiredDate); }else { if(size>0) { ExpiredDate = result[0]; PrintFormat("AFTER SPLIT : %s", ExpiredDate); StringReplace(ExpiredDate,"-","."); PrintFormat("AFTER REPLACE : %s", ExpiredDate); datetime d1=StrToTime(ExpiredDate); PrintFormat("Expire : %d - %s",d1, TimeToStr(d1,TIME_DATE|TIME_SECONDS)); datetime d2=TimeCurrent(); PrintFormat("Now : %d - %s",d2, TimeToStr(d2,TIME_DATE|TIME_SECONDS)); if(d1>d2) IsExpired = 0; else IsExpired = 1; ObjectSetString(0,DRAWUI_ACTTITLE,OBJPROP_TEXT,ExpiredDate); } } string handle = CreateExpiredDateToRegistry(Enkripsi(ExpiredDate1), Enkripsi(Your_Id)); if(handle !="") PrintFormat("%s",handle); }
Thx.
saptopriyono: Dear Metaquote,
| This is a user's forum not Metaquotes. Can someone please advise where I send a Request for Support to Metaquotes. - MQL4 forum or Get in touch with developers using Service Desk! - MQL5 forum |
Finally I use MqlDateTime (StructToTime) to construct time. Not using StrToTime. And everything is runing well.
ExpiredDate = result[0]; string sep1="-"; ushort u_sep1; string result1[]; u_sep1=StringGetCharacter(sep1,0); int k1=StringSplit(ExpiredDate,u_sep1,result1); int size1=ArraySize(result1); MqlDateTime dt_struct; if(size1>0) dt_struct.year = result1[0]; if(size1>1) dt_struct.mon = result1[1]; if(size1>2) dt_struct.day = result1[2]; datetime d1 = StructToTime(dt_struct);
Thx.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I search, where are the mistakes in RED TYPE (StrToTime function) that return wrong date value? The integer value of datetime is different, but TimeToStr give the same value.
Thx.