-
Notifications
You must be signed in to change notification settings - Fork 0
/
class_vector.cpp
80 lines (65 loc) · 1.35 KB
/
class_vector.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#pragma once
#include <string.h>
#include <iostream>
#include <stdio.h>
#include "class_point.cpp"
#include <time.h>
using namespace std;
class Vector
{
public:
Point start;
Point end;
string yymmdd;
int milliseconds;
int dateDay;
int dateYear;
Vector(double lon1, double lat1, double lon2, double lat2)
{
start.lon = lon1;
start.lat = lat1;
end.lon = lon2;
end.lat = lat2;
}
void to_ms_time(string hhmmss)
{
int milihh = stoi(hhmmss.substr(0, 2));
int milimm = stoi(hhmmss.substr(3, 2));
int miliss = stoi(hhmmss.substr(6, 2));
milliseconds = milihh * msInHour + milimm * msInMin + miliss * msInSec;
}
void to_date_day(string date)
{
int yyyy = stoi(yymmdd.substr(0, 4));
int mmmm = stoi(yymmdd.substr(5, 2));
int dddd = stoi(yymmdd.substr(8, 2));
dateYear = yyyy;
dateDay = monthInDay(yyyy, mmmm) + dddd;
}
private:
int monthInDay(int year, int month)
{
int dayArray[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int days = 0;
for (size_t i = 0; i < month - 1; i++)
{
days += dayArray[i];
}
if (month > 1)
{
days += visokosYear(year);
}
return days;
}
int visokosYear(int year)
{
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
{
return 1;
}
else
{
return 0;
}
}
};