autorest icon indicating copy to clipboard operation
autorest copied to clipboard

Date-time properties should be modeled as DateTimeOffset in C#

Open bitsforthought opened this issue 11 years ago • 4 comments

AutoRest currently generates properties of type DateTime? instead of DateTimeOffset?. This results in the loss of time zone information.

It looks like the place to fix this is in CSharpCodeNamer.NormalizePrimaryType.

bitsforthought avatar Nov 19 '15 01:11 bitsforthought

@brjohnstmsft what is the use case for DateTimeOffset and having timezone information available?

stankovski avatar Dec 01 '15 18:12 stankovski

@stankovski Data plane APIs like Azure Search that can store and retrieve date/time data with full time zone information. This saves clients from having to remember to normalize all DateTimes to UTC.

bitsforthought avatar Dec 01 '15 19:12 bitsforthought

I agree that DateTimeOffset should be used by default. It can be important to retain the original timezone of the data and not convert everything to UTC. I'm willing to make the change. I guess the question would be is there a need to make the model type configurable?

jhancock93 avatar Feb 04 '16 15:02 jhancock93

@jhancock93 I would make it an option on C# code generator not to break existing clients

stankovski avatar Feb 06 '16 01:02 stankovski