Skip to content

Commit 0e26834

Browse files
committed
Initial commit.
1 parent 7a2d704 commit 0e26834

File tree

60 files changed

+3086
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3086
-0
lines changed

.gitattributes

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
* text=auto
2+
3+
*.doc diff=astextplain
4+
*.DOC diff=astextplain
5+
*.docx diff=astextplain
6+
*.DOCX diff=astextplain
7+
*.dot diff=astextplain
8+
*.DOT diff=astextplain
9+
*.pdf diff=astextplain
10+
*.PDF diff=astextplain
11+
*.rtf diff=astextplain
12+
*.RTF diff=astextplain
13+
14+
*.bmp binary
15+
*.gif binary
16+
*.jpg binary
17+
*.png binary
18+
19+
*.ascx text
20+
*.cmd text
21+
*.coffee text
22+
*.config text
23+
*.cs text diff=csharp
24+
*.csproj text merge=union
25+
*.css text
26+
*.cshtml text
27+
*.htm text
28+
*.html text
29+
*.htm text
30+
*.js text
31+
*.msbuild text
32+
*.resx text merge=union
33+
*.ruleset text
34+
*.Stylecop text
35+
*.targets text
36+
*.tt text
37+
*.txt text
38+
*.vb text
39+
*.vbhtml text
40+
*.vbproj text merge=union
41+
*.xml text
42+
*.xunit text
43+
44+
*.sln text eol=crlf merge=union

Exceptionless.DateTimeExtensions.sln

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.30723.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DateTimeExtensions", "Source\DateTimeExtensions.csproj", "{2896EC87-4612-4A15-B2F2-6160E546EDCB}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DateTimeExtensions.Tests", "Source\Tests\DateTimeExtensions.Tests.csproj", "{A03B8B66-A0E0-46E6-961A-8EA6ACBFE58C}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{2896EC87-4612-4A15-B2F2-6160E546EDCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{2896EC87-4612-4A15-B2F2-6160E546EDCB}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{2896EC87-4612-4A15-B2F2-6160E546EDCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{2896EC87-4612-4A15-B2F2-6160E546EDCB}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{A03B8B66-A0E0-46E6-961A-8EA6ACBFE58C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{A03B8B66-A0E0-46E6-961A-8EA6ACBFE58C}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{A03B8B66-A0E0-46E6-961A-8EA6ACBFE58C}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{A03B8B66-A0E0-46E6-961A-8EA6ACBFE58C}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal

License.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Copyright (c) 2012, LoreSoft
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
6+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
Neither the name of LoreSoft nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Source/BusinessDay.cs

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
using System;
2+
using System.Diagnostics;
3+
4+
namespace Exceptionless.DateTimeExtensions
5+
{
6+
/// <summary>
7+
/// A class defining a business day.
8+
/// </summary>
9+
[DebuggerDisplay("DayOfWeek={DayOfWeek}, StartTime={StartTime}, EndTime={EndTime}")]
10+
public class BusinessDay
11+
{
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="BusinessDay"/> class.
14+
/// </summary>
15+
/// <param name="dayOfWeek">The day of week this business day represents.</param>
16+
public BusinessDay(DayOfWeek dayOfWeek)
17+
{
18+
StartTime = TimeSpan.FromHours(9); // 9am
19+
EndTime = TimeSpan.FromHours(17); // 5pm
20+
DayOfWeek = dayOfWeek;
21+
}
22+
23+
/// <summary>
24+
/// Initializes a new instance of the <see cref="BusinessDay"/> class.
25+
/// </summary>
26+
/// <param name="dayOfWeek">The day of week this business day represents.</param>
27+
/// <param name="startTime">The start time of the business day.</param>
28+
/// <param name="endTime">The end time of the business day.</param>
29+
public BusinessDay(DayOfWeek dayOfWeek, TimeSpan startTime, TimeSpan endTime)
30+
{
31+
if (startTime.TotalDays >= 1)
32+
throw new ArgumentOutOfRangeException("startTime", startTime, "The startTime argument must be less then one day.");
33+
34+
if (endTime.TotalDays > 1)
35+
throw new ArgumentOutOfRangeException("endTime", endTime, "The endTime argument must be less then one day.");
36+
37+
if (endTime <= startTime)
38+
throw new ArgumentOutOfRangeException("endTime", endTime, "The endTime argument must be greater then startTime.");
39+
40+
DayOfWeek = dayOfWeek;
41+
StartTime = startTime;
42+
EndTime = endTime;
43+
}
44+
45+
/// <summary>
46+
/// Gets the day of week this business day represents..
47+
/// </summary>
48+
/// <value>The day of week.</value>
49+
public DayOfWeek DayOfWeek { get; private set; }
50+
51+
/// <summary>
52+
/// Gets the start time of the business day.
53+
/// </summary>
54+
/// <value>The start time of the business day.</value>
55+
public TimeSpan StartTime { get; private set; }
56+
57+
/// <summary>
58+
/// Gets the end time of the business day.
59+
/// </summary>
60+
/// <value>The end time of the business day.</value>
61+
public TimeSpan EndTime { get; private set; }
62+
63+
/// <summary>
64+
/// Determines whether the specified date falls in the business day.
65+
/// </summary>
66+
/// <param name="date">The date to check.</param>
67+
/// <returns>
68+
/// <c>true</c> if the specified date falls in the business day; otherwise, <c>false</c>.
69+
/// </returns>
70+
public bool IsBusinessDay(DateTime date)
71+
{
72+
if (date.DayOfWeek != DayOfWeek)
73+
return false;
74+
75+
if (date.TimeOfDay < StartTime)
76+
return false;
77+
78+
if (date.TimeOfDay > EndTime)
79+
return false;
80+
81+
return true;
82+
}
83+
}
84+
}

0 commit comments

Comments
 (0)