forked from ulysses4ever/cs211-extra-task-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextra-task-1.cpp
51 lines (42 loc) · 857 Bytes
/
extra-task-1.cpp
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
#include <iostream>
#include <assert.h>
double seconds_difference(double time_1, double time_2)
{
return time_2 - time_1;
}
double hours_difference(double time_1, double time_2)
{
return (time_2 - time_1) / 3600.0;
}
double to_float_hours(int hours, int minutes, int seconds)
{
return hours + (minutes / 60.0) + (seconds / 3600.0);
}
double to_24_hour_clock(double hours)
{
while (hours >= 24)
{
hours -= 24;
}
return hours;
}
int get_seconds(int seconds)
{
return seconds % 60;
}
int get_hours(int seconds)
{
return seconds / 3600;
}
int get_minutes(int seconds)
{
return (seconds % 3600) / 60;
}
double time_to_utc(int utc_offset, double time)
{
return to_24_hour_clock(time - utc_offset);
}
double time_from_utc(int utc_offset, double time)
{
return to_24_hour_clock(time + utc_offset);
}