-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDateTimeExtensions.cs
More file actions
224 lines (189 loc) · 4.9 KB
/
DateTimeExtensions.cs
File metadata and controls
224 lines (189 loc) · 4.9 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.CompilerServices;
namespace TradingPlatform.BusinessLayer;
public static class DateTimeExtensions
{
[CompilerGenerated]
private sealed class 녴 : IEnumerable<DateTime>, IEnumerable, IEnumerator<DateTime>, IEnumerator, IDisposable
{
private int 놭놗;
private DateTime 놭뇂;
private int 놭놩;
private DateTime 놭녡;
public DateTime 놭녦;
private DayOfWeek 놭놀;
public DayOfWeek 놭놔;
private DateTime 놭놾;
private DateTime 놭뇀;
DateTime IEnumerator<DateTime>.Current
{
[DebuggerHidden]
get
{
return 놭뇂;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return 놭뇂;
}
}
[DebuggerHidden]
public 녴(int P_0)
{
놭놗 = P_0;
놭놩 = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
private void 녴()
{
놭놗 = -2;
}
void IDisposable.Dispose()
{
//ILSpy generated this explicit interface implementation from .override directive in 녴
this.녴();
}
private bool MoveNext()
{
switch (놭놗)
{
default:
return false;
case 0:
놭놗 = -1;
놭놾 = new DateTime(놭녡.Year, 놭녡.Month, 1);
놭뇀 = 놭놾.AddMonths(1);
while (놭놾 < 놭뇀 && 놭놾.DayOfWeek != 놭놀)
{
놭놾 = 놭놾.AddDays(1.0);
}
break;
case 1:
놭놗 = -1;
놭놾 = 놭놾.AddDays(7.0);
break;
}
if (놭놾 < 놭뇀)
{
놭뇂 = 놭놾;
놭놗 = 1;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
private void 놴()
{
throw new NotSupportedException();
}
void IEnumerator.Reset()
{
//ILSpy generated this explicit interface implementation from .override directive in 놴
this.놴();
}
[DebuggerHidden]
private IEnumerator<DateTime> 놂()
{
녴 녴;
if (놭놗 == -2 && 놭놩 == Environment.CurrentManagedThreadId)
{
놭놗 = 0;
녴 = this;
}
else
{
녴 = new 녴(0);
}
녴.놭녡 = 놭녦;
녴.놭놀 = 놭놔;
return 녴;
}
IEnumerator<DateTime> IEnumerable<DateTime>.GetEnumerator()
{
//ILSpy generated this explicit interface implementation from .override directive in 놂
return this.놂();
}
[DebuggerHidden]
private IEnumerator 놎()
{
return 놂();
}
IEnumerator IEnumerable.GetEnumerator()
{
//ILSpy generated this explicit interface implementation from .override directive in 놎
return this.놎();
}
}
public static DateTime ToSelectedTimeZone(this DateTime dt)
{
return Core.Instance.TimeUtils.ConvertFromUTCToSelectedTimeZone(dt);
}
public static DateTime FromSelectedTimeZoneToUtc(this DateTime dt)
{
return Core.Instance.TimeUtils.ConvertFromSelectedTimeZoneToUTC(dt);
}
public static DateTime TrimSeconds(this DateTime value)
{
return new DateTime(value.Year, value.Month, value.Day, value.Hour, value.Minute, 0, value.Kind);
}
public static DateTime CeilingTo(this DateTime value, TimeSpan timeSpan)
{
long num = value.Ticks % timeSpan.Ticks;
if (num == 0L)
{
return value;
}
return new DateTime(value.Ticks - num + timeSpan.Ticks, value.Kind);
}
public static DateTime CeilingTo(this DateTime value, Period period)
{
return value.CeilingTo(TimeSpan.FromTicks(period.Ticks));
}
public static DateTime FloorTo(this DateTime value, TimeSpan timeSpan)
{
return new DateTime(value.Ticks - value.Ticks % timeSpan.Ticks, value.Kind);
}
public static DateTime FloorTo(this DateTime value, Period period)
{
return value.FloorTo(TimeSpan.FromTicks(period.Ticks));
}
public static long ToUnixSeconds(this DateTime dateTime)
{
return new DateTimeOffset(dateTime).ToUnixTimeSeconds();
}
public static long ToUnixMilliseconds(this DateTime dateTime)
{
return new DateTimeOffset(dateTime).ToUnixTimeMilliseconds();
}
public static DateTime SetKind(this DateTime dateTime, DateTimeKind kind)
{
return new DateTime(dateTime.Ticks, kind);
}
public static int GetWeekOfYear(this DateTime dateTime, DayOfWeek firstWeekDay = DayOfWeek.Monday)
{
return CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstFullWeek, firstWeekDay);
}
[IteratorStateMachine(typeof(녴))]
public static IEnumerable<DateTime> GetDaysOfWeekForCurrMonth(this DateTime date, DayOfWeek dayOfWeek)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new 녴(-2)
{
놭녦 = date,
놭놔 = dayOfWeek
};
}
}