blob: a935b481b66aebc8521a24b18605dbb40e9ed1e5 (
plain)
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
41
42
43
44
45
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// Contains <see cref="DateTime"/> extension methods.
/// </summary>
public static class DateTimeExtensions
{
/// <summary>
/// Converts the DateTime instance to an accurate time string.
/// </summary>
/// <param name="date">The date.</param>
/// <returns></returns>
public static String ToTimeString(this DateTime date)
{
return date.ToString("HH:mm:ss.ff");
}
/// <summary>
/// Returns a string which can be used as a file name.
/// </summary>
/// <param name="date">The date.</param>
/// <returns></returns>
public static String ToFileName(this DateTime date)
{
return string.Format("{0:dd-MM-yyyy HH-mm-ss}", DateTime.Now);
}
/// <summary>
/// Determines whether the date between start and end.
/// </summary>
/// <param name="thisDateTime">The this date time.</param>
/// <param name="start">The start.</param>
/// <param name="end">The end.</param>
/// <returns>
/// <c>true</c> if the date between start and end; otherwise, <c>false</c>.
/// </returns>
public static bool IsBetween(this DateTime thisDateTime, DateTime start, DateTime end)
{
return thisDateTime >= start && thisDateTime <= end;
}
}
|