diff --git a/EvitaDB.Client/Converters/DataTypes/EvitaDataTypesConverter.cs b/EvitaDB.Client/Converters/DataTypes/EvitaDataTypesConverter.cs index ab1e172..143825b 100644 --- a/EvitaDB.Client/Converters/DataTypes/EvitaDataTypesConverter.cs +++ b/EvitaDB.Client/Converters/DataTypes/EvitaDataTypesConverter.cs @@ -649,15 +649,19 @@ public static Currency[] ToCurrencyArray(GrpcCurrencyArray arrayValue) public static DateTimeOffset ToDateTimeOffset(GrpcOffsetDateTime offsetDateTimeValue) { - if (string.IsNullOrEmpty(offsetDateTimeValue.Offset)) + try { + TimeSpan hourOffset = TimeSpan.FromHours(int.Parse(offsetDateTimeValue.Offset.Substring(1, 2))); + bool add = offsetDateTimeValue.Offset.ElementAt(0) == '+'; + TimeSpan offset = add ? hourOffset : hourOffset.Negate(); + return DateTimeOffset.FromUnixTimeSeconds(offsetDateTimeValue.Timestamp.Seconds) + .ToOffset(offset); + } + catch (Exception) + { + Console.WriteLine(offsetDateTimeValue.Timestamp + " " +offsetDateTimeValue.Offset); return DateTimeOffset.Now; } - TimeSpan hourOffset = TimeSpan.FromHours(int.Parse(offsetDateTimeValue.Offset.Substring(1, 2))); - bool add = offsetDateTimeValue.Offset.ElementAt(0) == '+'; - TimeSpan offset = add ? hourOffset : hourOffset.Negate(); - return DateTimeOffset.FromUnixTimeSeconds(offsetDateTimeValue.Timestamp.Seconds) - .ToOffset(offset); } public static DateTimeOffset[] ToDateTimeOffsetArray(GrpcOffsetDateTimeArray arrayValue)