StringtoTime() bug - function ignores time part, but date is ok

 

Hello,


I try to read out and compare price at fixed time every day. I use few time/date/string management functions, however I got stuck at StringToTime conversion, instead returning number of seconds passed until requested hh:mm:ss  it always returns seconds at 00:00. For example with the following code with fixed string:

Print("FIXED test string to time  2019.07.31 [02:27:39]:   ", StringToTime("2019.07.31 [02:27]"));


StrategyTester gives the following output:

2019.11.26 14:19:17.506    Core 1    2019.11.24 22:13:20   FIXED test string to time  2019.07.31 [02:27:39]:   2019.07.31 00:00:00


Is it a bug or just me?


thanks for your help in advance

 
BaronWawelski:

Hello,


I try to read out and compare price at fixed time every day. I use few time/date/string management functions, however I got stuck at StringToTime conversion, instead returning number of seconds passed until requested hh:mm:ss  it always returns seconds at 00:00. For example with the following code with fixed string:

Print("FIXED test string to time  2019.07.31 [02:27:39]:   ", StringToTime("2019.07.31 [02:27]"));


StrategyTester gives the following output:

2019.11.26 14:19:17.506    Core 1    2019.11.24 22:13:20   FIXED test string to time  2019.07.31 [02:27:39]:   2019.07.31 00:00:00


Is it a bug or just me?


thanks for your help in advance

Just you :-)

The [] in the documentation means the [hour:minute:seconds] is optional. It doesn't mean you can use these characters in the string.

 
Alain Verleyen:

Just you :-)

The [] in the documentation means the [hour:minute:seconds] is optional. It doesn't mean you can use these characters in the string.

to use [ and ] is not an option, I see.

it works now.

thanks

Reason: