-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDateTimeColumn.cs
More file actions
40 lines (35 loc) · 1.26 KB
/
DateTimeColumn.cs
File metadata and controls
40 lines (35 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
namespace Queries.Core.Parts.Columns;
/// <summary>
/// Column that contains <see cref="DateTime"/>/<see cref="DateTimeOffset"/> value.
/// </summary>
public class DateTimeColumn : Literal, IFormattableColumn<DateTimeColumn>
{
/// <summary>
/// Format used when displaying columns value
/// </summary>
public string StringFormat { get; private set; }
/// <summary>
/// Builds a new <see cref="DateTimeColumn"/> instance.
/// </summary>
/// <param name="value">value of the column</param>
public DateTimeColumn(DateTime value) : this(value, "yyyy-MM-dd")
{}
/// <summary>
/// Builds a new <see cref="DateTimeColumn"/> instance.
/// </summary>
/// <param name="value">value of the column</param>
/// <param name="stringFormat">Format of the column</param>
public DateTimeColumn(DateTime value, string stringFormat) : base(value) => StringFormat = stringFormat;
/// <summary>
/// Specifies an output format
/// </summary>
/// <param name="format">format to apply</param>
/// <returns></returns>
public DateTimeColumn Format(string format)
{
//TODO check that format conforms to RFC if not throw a exception
StringFormat = format;
return this;
}
}