Nikey646 / VndbSharp

A C# Vndb API Library. #OriginalNamingScheme
MIT License
18 stars 4 forks source link

Error with DurationToDateTimeOffsetConverter #37

Closed micah686 closed 7 years ago

micah686 commented 7 years ago

After getting a throttled cmd error, VndbSharp attempts to run the DurationToDateTimeOffsetConverter ReadJson() method. However, when it tries to run return new DateTimeOffset(DateTime.Now).ToOffset(TimeSpan.FromSeconds(seconds));, it gives a System.ArgumentException: 'Offset must be specified in whole minutes.'.

I've had the seconds equal from 3.2 up to 608.5, but it always seems to trigger that error.

On a somewhat related note: InReadJson(...., Object existingValue,...), the existingValue always seems to be{1/1/0001 12:00:00 AM +00:00}, instead of the current DateTime. I'm not sure if that is relevant or not.

Perhaps using TimeSpan instead of DateTimeOffset would solve the issue? It seems like DateTimeOffset isn't really meant for precise offsets in seconds.

Nikey646 commented 7 years ago

Can you provide the full json response given when a Throttle Error is returned from the API?

I've never actually tried to be throttled to test that part of the code, so it has been conceptual the entire time.

micah686 commented 7 years ago

Here you go: Get Response | error {"msg":"Throttle limit reached.","fullwait":603.4,"minwait":3.4,"type":"cmd","id":"throttled"} {"msg":"Throttle limit reached.","fullwait":603.4,"minwait":3.4,"type":"cmd","id":"throttled"}

Nikey646 commented 7 years ago

Can you try that change?

micah686 commented 7 years ago

That seemed to fix it.