dimanche 7 février 2021

DateTime pattern for optional "Time" part?

I'm about to define a REST API that will expose a parameter that should accept a "DateTime" where the "Time"-part is optional. What would be the best solution for this? Please consider the following alternatives below, is there a better solution?

Separate parameters for date and time:

public DateTime DeliveryDate { get; set; }
public TimeSpan? DeliveryTime { get; set; } // Use a DateTime?

Separate parameter defining if the time part of the DateTime should be considered:

public DateTime DeliveryDate { get; set; }
public bool DeliveryTimeSpecified { get; set; }

Aucun commentaire:

Enregistrer un commentaire