daterange format
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace zero.Utils;
|
||||
namespace zero.Utils;
|
||||
|
||||
public class DateRange
|
||||
{
|
||||
@@ -8,6 +6,7 @@ public class DateRange
|
||||
|
||||
public DateTimeOffset? To { get; set; }
|
||||
|
||||
|
||||
public bool IsWithin(DateTimeOffset date)
|
||||
{
|
||||
if (From.HasValue && date < From)
|
||||
@@ -20,4 +19,22 @@ public class DateRange
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public string Format(string format)
|
||||
{
|
||||
if (!From.HasValue && !To.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (!From.HasValue && To.HasValue)
|
||||
{
|
||||
return "≤ " + To.Value.ToString(format);
|
||||
}
|
||||
if (From.HasValue && !To.HasValue)
|
||||
{
|
||||
return "≥ " + From.Value.ToString(format);
|
||||
}
|
||||
return From.Value.ToString(format) + " – " + To.Value.ToString(format);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user