diff --git a/src/ConfigCatClient/User.cs b/src/ConfigCatClient/User.cs index 603f15cf..e0a2f897 100644 --- a/src/ConfigCatClient/User.cs +++ b/src/ConfigCatClient/User.cs @@ -1,4 +1,7 @@ +using System; using System.Collections.Generic; +using System.Globalization; +using ConfigCat.Client.Utils; #if USE_NEWTONSOFT_JSON using Newtonsoft.Json; @@ -13,6 +16,27 @@ namespace ConfigCat.Client; /// public class User { + /// + /// Converts the specified value to the format expected by UTC datetime comparison operators. + /// + /// The value to convert. + /// The User Object attribute value in the expected format. + public static string MakeAttributeValue(DateTime dateTime) + { + var unixTimeSeconds = DateTimeUtils.ToUnixTimeMilliseconds(dateTime) / 1000.0; + return unixTimeSeconds.ToString("0.###", CultureInfo.InvariantCulture); + } + + /// + /// Converts the specified value to the format expected by number comparison operators. + /// + /// The value to convert. + /// The User Object attribute value in the expected format. + public static string MakeAttributeValue(double number) + { + return number.ToString("g", CultureInfo.InvariantCulture); // format "g" allows scientific notation as well + } + internal const string DefaultIdentifierValue = ""; ///