Dahomey.Cbor icon indicating copy to clipboard operation
Dahomey.Cbor copied to clipboard

In DateTimeConverter, let DateTime.Kind be unspecified if it is in fact unspecified

Open rmja opened this issue 3 years ago • 1 comments

Currently, in DateTimeConverter, the DateTimeKind is set to Local if no timezone is specified. It would probably be more correct to let it be Unspecified. I know this is a breaking change, but maybe we could have a "UnspecifiedDateTimeKind" option on CborOptions similar to DateTimeFormat so that it is configurable? In my use case I need a DateTime to come back as Unspecified when no timezone details are present.

rmja avatar Jul 01 '22 07:07 rmja

The same is also true for the case when the timezone details is in fact specified. Currently a DateTime is returned of type "Local", but this should probably also be Unspecifed.

rmja avatar Jul 01 '22 07:07 rmja

fair enough when no timezone is specified. However, when a timezone is specified, I think it should be better to return the UTC equivalent because we need to calculate the offset from a reference. e.g. 1977-04-22T01:00:00-05:00 is equivalent to 1977-04-22T06:00:00Z

mcatanzariti avatar Oct 24 '22 20:10 mcatanzariti