Skip to content

Commit 11a23a1

Browse files
committed
ToTimeUnit() does not serialize to year units
A year is not a fixed unit of time when converting from TotalMilliseconds Fixes #2022
1 parent 9d8c1ce commit 11a23a1

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

Diff for: src/Elasticsearch.Net/Extensions/Extensions.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,10 @@ internal static IEnumerable<T> DistinctBy<T, TKey>(this IEnumerable<T> items, Fu
9797
internal static string ToTimeUnit(this TimeSpan timeSpan)
9898
{
9999
var ms = timeSpan.TotalMilliseconds;
100-
var interval = "ms";
100+
string interval;
101101
double factor = 0;
102102

103-
if (ms >= _year)
104-
{
105-
factor = ms / _year;
106-
interval = "y";
107-
}
108-
else if (ms >= _week)
103+
if (ms >= _week)
109104
{
110105
factor = ms / _week;
111106
interval = "w";

0 commit comments

Comments
 (0)