Black Rock Reporting Azure Function
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

TimeOnlyConverter.cs 827B

12345678910111213141516171819202122232425
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Newtonsoft.Json;
  8. namespace BlackRockReportFunction.Helpers
  9. {
  10. public class TimeOnlyConverter : JsonConverter<TimeOnly>
  11. {
  12. private const string Format = "hh:mm:ss";
  13. public override TimeOnly ReadJson(JsonReader reader,
  14. Type objectType,
  15. TimeOnly existingValue,
  16. bool hasExistingValue,
  17. JsonSerializer serializer) =>
  18. TimeOnly.ParseExact((string)reader.Value, Format, CultureInfo.InvariantCulture);
  19. public override void WriteJson(JsonWriter writer, TimeOnly value, JsonSerializer serializer) =>
  20. writer.WriteValue(value.ToString(Format, CultureInfo.InvariantCulture));
  21. }
  22. }