ValveKeyValue icon indicating copy to clipboard operation
ValveKeyValue copied to clipboard

Casting to DateTime is not supported

Open xPaw opened this issue 3 years ago • 4 comments

There's this: https://github.com/SteamDatabase/ValveKeyValue/blob/225ef38dca38bb83aefe3c43c65822d64c85b01c/ValveKeyValue/ValveKeyValue/KVObjectValue.cs#L44-L47

However TryConvertValueTo listed it as a supported conversion: https://github.com/SteamDatabase/ValveKeyValue/blob/dfb96b52087fbd4f27e4128a5368cf318a04412b/ValveKeyValue/ValveKeyValue/ObjectCopier.cs#L407

I commented that out for now, was it simply never finished?

xPaw avatar Oct 07 '22 09:10 xPaw

I think it was there because IConvertible officially supports DateTime, but we never implemented it as there's no strict definition of what a KV DateTime looks like - could be a string with a million formats, or unix time integer, or perhaps even valve time integer (GID_t epoch).

yaakov-h avatar Oct 08 '22 09:10 yaakov-h

So removing it from TryConvertValueTo should be correct then.

xPaw avatar Oct 08 '22 09:10 xPaw

I think so, but you'll just get a NotSupportedException instead. Which is probably the correct exception here.

yaakov-h avatar Oct 08 '22 09:10 yaakov-h

You do, which is more helpful due to a better exception message: eb5d13f301d1487836702070c36fb77b95a5a3ec

xPaw avatar Oct 08 '22 09:10 xPaw