Skip to content

Commit 4f409eb

Browse files
committed
perf(serilog-middleware): remove endDate fixed-time change, since UI manages date&time
1 parent 5e2d5ff commit 4f409eb

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/Serilog.Ui.Web/SerilogUiMiddleware.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using Newtonsoft.Json.Serialization;
1212
using Serilog.Ui.Core;
1313
using System;
14-
using System.Diagnostics;
14+
using System.Globalization;
1515
using System.IO;
1616
using System.Linq;
1717
using System.Net;
@@ -154,19 +154,15 @@ private async Task<string> FetchLogsAsync(HttpContext httpContext)
154154
int.TryParse(pageStr, out var currentPage);
155155
int.TryParse(countStr, out var count);
156156

157-
DateTime.TryParse(startDateStar, out var startDate);
158-
DateTime.TryParse(endDateStar, out var endDate);
159-
160-
if (endDate != default)
161-
endDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59);
157+
DateTime.TryParse(startDateStar, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var startDate);
158+
DateTime.TryParse(endDateStar, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var endDate);
162159

163160
currentPage = currentPage == default ? 1 : currentPage;
164161
count = count == default ? 10 : count;
165162

166163
var provider = httpContext.RequestServices.GetService<IDataProvider>();
167164
var (logs, total) = await provider.FetchDataAsync(currentPage, count, levelStr, searchStr,
168165
startDate == default ? (DateTime?)null : startDate, endDate == default ? (DateTime?)null : endDate);
169-
//var result = JsonSerializer.Serialize(logs, _jsonSerializerOptions);
170166
var result = JsonConvert.SerializeObject(new { logs, total, count, currentPage }, _jsonSerializerOptions);
171167
return result;
172168
}

0 commit comments

Comments
 (0)