-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkTime.cs
More file actions
52 lines (43 loc) · 1.41 KB
/
WorkTime.cs
File metadata and controls
52 lines (43 loc) · 1.41 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
/*
* WORK TIME CONTROL
*
*
* This Script is to verify the hours I can leave the office
*/
using System;
// Variables
var interval = new TimeSpan(1,0,0); // 1h interval
var hourDay = new TimeSpan(8,48,0); // 8h48 of worktime daily
var maxTimeDay = new TimeSpan(10,0,0); // 10h of maximum time daily
Console.Write("> Enter the starting work time (HH:MM) : ");
#pragma warning disable CS8600
string entry = Console.ReadLine();
Console.WriteLine("\n");
#pragma warning disable CS8602
if (entry.Contains(":"))
{
string[] entrySplit = entry.Split(":");
var startingTime = new TimeSpan(Int32.Parse(entrySplit[0]), Int32.Parse(entrySplit[1]), 0);
var expectedLeave = startingTime + interval + hourDay;
var maximumLeave = startingTime + interval + maxTimeDay;
// Show the start time in console
Console.Write("STARTING TIME: ");
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine($"{startingTime}");
Console.ResetColor();
// Show the expected end time in console
Console.Write("EXPECTED TIME LEAVE: ");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"{expectedLeave}");
Console.ResetColor();
// Show the maximum end time in console
Console.Write("MAXIMUM TIME LEAVE: ");
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"{maximumLeave}");
Console.ResetColor();
}
else
{
Console.WriteLine("ERROR! Time structure not valid.");
}
Console.WriteLine("\n");