Preserve controle recebidos dates as UTC noon
This commit is contained in:
parent
89252307a3
commit
70f916ba19
|
|
@ -1856,20 +1856,25 @@ namespace line_gestao_api.Controllers
|
|||
var cell = ws.Cell(row, col);
|
||||
|
||||
if (cell.DataType == XLDataType.DateTime)
|
||||
return DateTime.SpecifyKind(cell.GetDateTime(), DateTimeKind.Utc);
|
||||
return ToUtcDateOnly(cell.GetDateTime());
|
||||
|
||||
if (cell.TryGetValue<DateTime>(out var dt))
|
||||
return DateTime.SpecifyKind(dt, DateTimeKind.Utc);
|
||||
return ToUtcDateOnly(dt);
|
||||
|
||||
var s = cell.GetValue<string>()?.Trim();
|
||||
if (string.IsNullOrWhiteSpace(s)) return null;
|
||||
|
||||
if (DateTime.TryParse(s, new CultureInfo("pt-BR"), DateTimeStyles.None, out var d))
|
||||
return DateTime.SpecifyKind(d, DateTimeKind.Utc);
|
||||
return ToUtcDateOnly(d);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static DateTime ToUtcDateOnly(DateTime dt)
|
||||
{
|
||||
return new DateTime(dt.Year, dt.Month, dt.Day, 12, 0, 0, DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
private static decimal? TryDecimal(string? s)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(s)) return null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue