Skip to content

Commit f0d0857

Browse files
committed
Initial Uncompleted project commit
1 parent 97dc253 commit f0d0857

File tree

197 files changed

+36573
-1
lines changed

Some content is hidden

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

197 files changed

+36573
-1
lines changed

.gitattributes

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# User-specific files
77
*.suo
8-
*.user
8+
# *.user
99
*.userosscache
1010
*.sln.docstates
1111

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
3+
namespace FsNet.Common.DatetimeUtils
4+
{
5+
public class DateTimeRange
6+
{
7+
private DateTime _startDate;
8+
private DateTime _endDate;
9+
10+
private static DateTime BaseDateStart
11+
{
12+
get
13+
{
14+
var cur = DateTime.Now;
15+
return new DateTime(cur.Year, cur.Month, cur.Day, 0, 0, 0, 0);
16+
}
17+
}
18+
private static DateTime BaseDateEnd
19+
{
20+
get
21+
{
22+
var cur = DateTime.Now;
23+
return new DateTime(cur.Year, cur.Month, cur.Day, 23, 59, 59, 999);
24+
}
25+
}
26+
27+
public DateTime StartDate {
28+
get => _startDate;
29+
set => _startDate = value;
30+
}
31+
public DateTime EndDate {
32+
get => _endDate;
33+
set => _endDate = value;
34+
}
35+
36+
public DateTimeRange() : this(BaseDateStart, BaseDateEnd) { }
37+
public DateTimeRange(DateTime startDate, DateTime endDate)
38+
{
39+
_startDate = startDate;
40+
_endDate = endDate;
41+
}
42+
43+
public bool IsBetween(DateTimeRange dateRange)
44+
{
45+
return dateRange.IsInRange(StartDate) && dateRange.IsInRange(EndDate);
46+
}
47+
48+
public bool IsInRange(DateTime dateTime)
49+
{
50+
return dateTime >= StartDate && dateTime <= EndDate;
51+
}
52+
53+
public bool ColideWith(DateTimeRange range)
54+
{
55+
return range.IsInRange(StartDate) || range.IsInRange(EndDate) || IsInRange(range.StartDate) || IsInRange(range.EndDate);
56+
}
57+
}
58+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.Globalization;
3+
4+
namespace FsNet.Common.DatetimeUtils
5+
{
6+
public class PersianDate
7+
{
8+
public int Year { get; set; }
9+
public int Mounth { get; set; }
10+
public int DayOfMounth { get; set; }
11+
public int DayOfWeek { get; set; }
12+
public int Hour { get; set; }
13+
public int Minute { get; set; }
14+
public int Second { get; set; }
15+
16+
public override string ToString()
17+
{
18+
return $"{Year:D4}/{Mounth:D2}/{DayOfMounth:D2}~{new Time() {Hour = this.Hour, Minute = this.Minute, Second = this.Second}}";
19+
}
20+
21+
public string ToRtlString()
22+
{
23+
return $"{new Time() { Hour = this.Hour, Minute = this.Minute, Second = this.Second }}~{Year:D4}/{Mounth:D2}/{DayOfMounth:D2}";
24+
}
25+
26+
public string ToDateString()
27+
{
28+
return $"{Year:D4}/{Mounth:D2}/{DayOfMounth:D2}";
29+
}
30+
31+
public DateTime ToDateTime()
32+
{
33+
var pc = new PersianCalendar();
34+
return pc.ToDateTime(Year, Mounth, DayOfMounth, Hour, Minute, Second, 0);
35+
}
36+
37+
}
38+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
namespace FsNet.Common.DatetimeUtils
2+
{
3+
public enum PersianMounth
4+
{
5+
Farvardin = 1,
6+
Ordibehesht = 2,
7+
Khordad = 3,
8+
Tir = 4,
9+
Mordad = 5,
10+
Sharhrivar = 6,
11+
Mehr = 7,
12+
Aban = 8,
13+
Azar = 9,
14+
Dey = 10,
15+
Bahman = 11,
16+
Esfand = 12
17+
}
18+
19+
public static class PersianMounthExtentions
20+
{
21+
public static string ToPersianString(this PersianMounth mounth)
22+
{
23+
switch (mounth)
24+
{
25+
case PersianMounth.Farvardin: return Properties.Resources.Farvardin;
26+
case PersianMounth.Ordibehesht: return Properties.Resources.Ordibehesht;
27+
case PersianMounth.Khordad: return Properties.Resources.Khordad;
28+
case PersianMounth.Tir: return Properties.Resources.Tir;
29+
case PersianMounth.Mordad: return Properties.Resources.Mordad;
30+
case PersianMounth.Sharhrivar: return Properties.Resources.Shahrivar;
31+
case PersianMounth.Mehr: return Properties.Resources.Mehr;
32+
case PersianMounth.Aban: return Properties.Resources.Aban;
33+
case PersianMounth.Azar: return Properties.Resources.Azar;
34+
case PersianMounth.Dey: return Properties.Resources.Dey;
35+
case PersianMounth.Bahman: return Properties.Resources.Bahman;
36+
case PersianMounth.Esfand: return Properties.Resources.Esfand;
37+
}
38+
return null;
39+
}
40+
}
41+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
using System.ComponentModel;
2+
using System.Globalization;
3+
4+
namespace FsNet.Common.DatetimeUtils
5+
{
6+
public class Time
7+
{
8+
public Time() { }
9+
10+
11+
public Time(int hour, int minute)
12+
: this(hour, minute, 0, 0)
13+
{
14+
15+
}
16+
public Time(int hour, int minute, int second)
17+
: this(hour, minute, second, 0)
18+
{
19+
20+
}
21+
22+
public Time(int hour, int minute, int second, int miliSeconds)
23+
{
24+
Hour = hour;
25+
Minute = minute;
26+
Second = second;
27+
Milisecond = miliSeconds;
28+
}
29+
30+
[DefaultValue(-1)]
31+
public int Hour { get; set; }
32+
public int Minute { get; set; }
33+
public int Second { get; set; }
34+
public int Milisecond { get; set; }
35+
36+
public string ToLongString()
37+
{
38+
return $"{Hour:D2}:{Minute:D2}:{Second:D2}.{Milisecond.ToString(CultureInfo.InvariantCulture).PadLeft(3, '0')}";
39+
}
40+
public override string ToString()
41+
{
42+
return $"{Hour:D2}:{Minute:D2}:{Second:D2}";
43+
}
44+
45+
public string ToShortString()
46+
{
47+
return $"{Minute:D2}:{Second:D2}";
48+
}
49+
50+
public static bool operator >(Time _this, Time that)
51+
{
52+
return _this.Hour > that.Hour || (_this.Hour == that.Hour && _this.Minute > that.Minute) ||
53+
(_this.Hour == that.Hour && _this.Minute == that.Minute && _this.Second > that.Second) ||
54+
(_this.Hour == that.Hour && _this.Minute == that.Minute && _this.Second == that.Second && _this.Milisecond > that.Milisecond);
55+
}
56+
57+
public static bool operator <(Time _this, Time that)
58+
{
59+
return _this.Hour < that.Hour || (_this.Hour == that.Hour && _this.Minute < that.Minute) ||
60+
(_this.Hour == that.Hour && _this.Minute == that.Minute && _this.Second < that.Second) ||
61+
(_this.Hour == that.Hour && _this.Minute == that.Minute && _this.Second == that.Second && _this.Milisecond < that.Milisecond);
62+
}
63+
64+
public static bool operator ==(Time _this, Time that)
65+
{
66+
if (null == (object)_this && (object)that == null) return true;
67+
if (null == (object)_this || (null == (object)that)) return false;
68+
69+
return _this.Hour == that.Hour && _this.Minute == that.Minute && _this.Second == that.Second && _this.Milisecond == that.Milisecond;
70+
}
71+
72+
public static bool operator !=(Time _this, Time that)
73+
{
74+
return !(_this == that);
75+
}
76+
77+
public static bool operator >=(Time _this, Time that)
78+
{
79+
return (_this == that || _this > that);
80+
}
81+
82+
public static bool operator <=(Time _this, Time that)
83+
{
84+
return (_this == that || _this < that);
85+
}
86+
87+
protected bool Equals(Time other)
88+
{
89+
return Hour == other.Hour && Minute == other.Minute && Second == other.Second && Milisecond == other.Milisecond;
90+
}
91+
92+
public override bool Equals(object obj)
93+
{
94+
if (ReferenceEquals(null, obj)) return false;
95+
if (ReferenceEquals(this, obj)) return true;
96+
return obj.GetType() == typeof(Time) && Equals((Time)obj);
97+
}
98+
99+
public override int GetHashCode()
100+
{
101+
//FNV hash algothm
102+
unchecked
103+
{
104+
const int prime = 23497;//big enough prime number
105+
var hashCode = Hour;
106+
hashCode = (hashCode * prime) ^ Minute;
107+
hashCode = (hashCode * prime) ^ Second;
108+
hashCode = (hashCode * prime) ^ Milisecond;
109+
return hashCode;
110+
}
111+
}
112+
113+
public bool IsValid()
114+
{
115+
return Hour >= 0 && Hour < 24 && Minute >= 0 && Minute < 60 && Second >= 0 && Second < 60 && Milisecond >= 0 && Milisecond < 1000;
116+
}
117+
}
118+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
namespace FsNet.Common.DatetimeUtils
2+
{
3+
public class TimeRange
4+
{
5+
public TimeRange() : this(new Time(23, 59, 59), new Time(0, 0, 0)) { }
6+
public TimeRange(Time startTime, Time endTime)
7+
{
8+
StartTime = startTime;
9+
EndTime = endTime;
10+
}
11+
12+
public Time StartTime { get; set; }
13+
public Time EndTime { get; set; }
14+
15+
public string StartTimeStr => $"{StartTime.Hour:D2}:{StartTime.Minute:D2}:{StartTime.Second:D2}";
16+
public string EndTimeStr => $"{EndTime.Hour:D2}:{EndTime.Minute:D2}:{EndTime.Second:D2}";
17+
18+
public bool IsBetween(TimeRange timeRange)
19+
{
20+
return timeRange.IsInRange(StartTime) && timeRange.IsInRange(EndTime);
21+
}
22+
23+
public bool IsInRange(Time time)
24+
{
25+
if (EndTime >= StartTime) return time >= StartTime && time <= EndTime;
26+
return (time >= StartTime && time >= EndTime);
27+
}
28+
29+
public bool ColideWith(TimeRange range)
30+
{
31+
return range.IsInRange(StartTime) || range.IsInRange(EndTime) || IsInRange(range.StartTime) || IsInRange(range.EndTime);
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)