kontent-ai / model-generator-net

Kontent.ai .NET model generator.
https://www.nuget.org/packages/Kontent.Ai.ModelGenerator
MIT License
17 stars 18 forks source link

Support for DateTime element timezones #172

Closed Sevitas closed 1 year ago

Sevitas commented 1 year ago

Motivation

As part of #356 we added new DateTimeContentConverter to Delivery .NET SDK to have a possibility to convert DateTimeElement to custom DateTimeContent model, which has the following interface:

public interface IDateTimeContent
{
    public DateTime? Value { get; }
    public string DisplayTimezone { get; }
}

At the same time, we kept the possibility to convert DateTimeElement to system DateTime? type the same as it worked before.

It's needed to extend the model generator's functionality to let customers choose, whether they want to convert DateTimeElement to simple DateTime? value (previous behavior) or to custom IDateTimeContent model.

Proposed solution

It seems reasonable to use similar approach as for RichTextElement converting. Model generator creates a property of string or custom IRichTextContent model depending on --structuredmodel <True|False> parameter value. As we discussed on grooming, we can change type of structuredmodel property from current bool to string, so that it will contain a list of element types, for which custom type will be generated. Currently, there will be two possible elements, for with structured model could be generated:

So, possible structuredmodel property format could be --structuredmodel richtext|datetime

Additional context

Add any other context, screenshots, or reference links about the feature request here.

Simply007 commented 1 year ago

Add information about this feature to https://github.com/kontent-ai/delivery-sdk-net/blob/master/docs/customization-and-extensibility/rich-text/structured-rich-text-rendering.md

Once released also linked the link above from https://github.com/kontent-ai/delivery-sdk-net/issues/356#issuecomment-1413360086 (updated as a part of https://github.com/kontent-ai/delivery-sdk-net/issues/356) (update of neccesarry)

dzmitryk-kontent-ai commented 1 year ago

Also, please, update information about this feature to https://github.com/kontent-ai/delivery-sdk-net/blob/master/docs/customization-and-extensibility/strong-types-explained/code-generator.md