-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCACE.cs
More file actions
66 lines (57 loc) · 1.91 KB
/
CACE.cs
File metadata and controls
66 lines (57 loc) · 1.91 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HourlySign
{
class CACE : IComparable<CACE>
{
public DateTime DateTime { get; }
public string FirstName { get; }
public string LastName { get; }
public string Reason { get; }
public string Subject { get; }
public CACE(string dateTime, string firstName,
string lastName, string reason, string subject)
{
DateTime = parseDateTime(dateTime);
FirstName = firstName;
LastName = lastName;
Reason = reason;
Subject = subject;
}
private DateTime parseDateTime(string dateTime)
{
string[] split = dateTime.Split(new Char[] {'/', ':', ' '});
int month, day, year, hour, minute, second;
string period; //AM or PM
month = Int32.Parse(split[0]);
day = Int32.Parse(split[1]);
year = Int32.Parse(split[2]);
hour = Int32.Parse(split[3]);
minute = Int32.Parse(split[4]);
second = Int32.Parse(split[5]);
period = split[6];
hour = convertToMilitaryTime(hour, period);
return new DateTime(year, month, day, hour, minute, second);
}
private int convertToMilitaryTime(int hour, string period)
{
if (period.Equals("PM") && hour != 12)
hour += 12;
if (period.Equals("AM") && hour == 12)
hour += 12;
return hour;
}
public string ToString()
{
return DateTime.ToString() + " " + FirstName + " " +
LastName + " " + Reason + " " + Subject;
}
public int CompareTo(CACE other)
{
return this.DateTime.CompareTo(other.DateTime);
}
}
}