Server time or time zone info is wrong

Created at 22 May 2016, 19:30
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MO

moneybiz

Joined 06.12.2011

Server time or time zone info is wrong
22 May 2016, 19:30


The Spotware's cAlgo server's time information seems to be wrong or TimeZone.BaseUtcOffset does not reflect the correct offset.

var serverTime = new DateTimeOffset(Time, TimeZone.BaseUtcOffset);
var utcNow = DateTimeOffset.UtcNow;
Print($"Server time: {Time:yyyy-MM-dd HH:mm:ss}");
Print($"Server UTC Offset: {TimeZone.BaseUtcOffset}");
Print($"Server time with UTC Offset: {serverTime:yyyy-MM-dd HH:mm:ss zzz}");
Print($"UTC Now: {utcNow:yyyy-MM-dd HH:mm:ss zzz}");

Output:

22/05/2016 19:01:57.202 | Server time: 2016-05-22 17:01:57
22/05/2016 19:01:57.202 | Server UTC Offset: 00:00:00
22/05/2016 19:01:57.202 | Server time with UTC Offset: 2016-05-22 17:01:57 +00:00
22/05/2016 19:01:57.202 | UTC Now: 2016-05-22 16:01:57 +00:00

If the server's time is correct then the offset values has to be +01:00. If the offset is correct then the time value is wrong.

I think the time is correct but the offset is wrong.
My time zone is +03:00 with daylight saving regime otherwise it is +02:00. London's time zone is 01:00 with daylight saving regime otherwise it's 00:00. I checked online and it's same with the server's time value but offset is +01:00.
So, the 
TimeZone.BaseUtcOffset value is wrong. Needs to be corrected.


@moneybiz
Replies

whis.gg
23 May 2016, 00:38

I came across same issue with offset giving me wrong values. Try following snippet, it worked for me.

TimeSpan offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow);

 


@whis.gg

moneybiz
23 May 2016, 10:35

RE:

tmc. said:

I came across same issue with offset giving me wrong values. Try following snippet, it worked for me.

TimeSpan offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow);

Doesn't this give your local time offset from UTC? It doesn't have anything to do with server's UTC offset.


@moneybiz

Spotware
23 May 2016, 11:01

Dear Trader,

Thank you for reporting it. We will investigate.


@Spotware

whis.gg
23 May 2016, 11:15

RE: RE:

moneybiz said:

tmc. said:

I came across same issue with offset giving me wrong values. Try following snippet, it worked for me.

TimeSpan offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow);

Doesn't this give your local time offset from UTC? It doesn't have anything to do with server's UTC offset.

Oh sorry, I misread your issue. Try the following.

Print(TimeZone.GetUtcOffset(Server.Time));

 


@whis.gg

moneybiz
23 May 2016, 13:19

RE: RE: RE:

tmc. said:

Oh sorry, I misread your issue. Try the following.

Print(TimeZone.GetUtcOffset(Server.Time));

I don't need to try because Server.Time doesn't carry time zone/offset component inside.


@moneybiz