fix: Use double precision for X-Reset-After, set CultureInfo when parsing numeric types (#1375)
* Parse double for X-Reset-After instead of float, needs more precision Float did not contain enough precision to store the millisecond unix time value, which resulted in the second and millisecond values being slightly off. This can be easily tested using: ```cs > DateTimeOffset.FromUnixTimeMilliseconds((long)(1470173022.123f * 1000)).Millisecond 160 // wrong > DateTimeOffset.FromUnixTimeMilliseconds((long)(1470173022.123 * 1000)).Millisecond 123 // correct ``` * Parse RateLimit-Reset using an IFormatProvider * State NumberStyle and use CultureInfo.InvariantCulture for any parsing This updates most occurances in the code where a Parse or TryParse method was used to explicitly state the NumberStyle, and to use CultureInfo.InvariantCulture. CultureInfo was used over NumberInfo, as it also works on DateTime parsing too. * Use default format spec in Commands
This commit is contained in:
committed by
Christopher F
parent
3755a027b3
commit
606dac3e1a
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
@@ -132,7 +133,7 @@ namespace Discord.Webhook
|
||||
{
|
||||
// ensure that the first group is a ulong, set the _webhookId
|
||||
// 0th group is always the entire match, so start at index 1
|
||||
if (!(match.Groups[1].Success && ulong.TryParse(match.Groups[1].Value, out webhookId)))
|
||||
if (!(match.Groups[1].Success && ulong.TryParse(match.Groups[1].Value, NumberStyles.None, CultureInfo.InvariantCulture, out webhookId)))
|
||||
throw ex("The webhook Id could not be parsed.");
|
||||
|
||||
if (!match.Groups[2].Success)
|
||||
|
||||
Reference in New Issue
Block a user