-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStartandSend.cpp
48 lines (36 loc) · 1.01 KB
/
StartandSend.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
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
class StartandSend{
public:
StartandSend(){
}
std::string getCurrentDateTime() {
time_t now = time(0);
tm* localTime = localtime(&now);
char buffer[80];
strftime(buffer, sizeof(buffer), "%H:%M:%S", localTime);
return std::string(buffer);
}
std::string getCurrentDate() {
time_t now = time(0);
tm* localTime = localtime(&now);
char buffer[80];
strftime(buffer, sizeof(buffer), "%Y-%m-%d", localTime);
return std::string(buffer);
}
std::string start() {
// Create a file named with the current date
std::string date = getCurrentDate();
std::string updateCommand = "start";
std::string dataFile = "/DataSets" + date + ".txt";
std::ofstream outFile(dataFile);
if (!outFile) {
std::cerr << "Error opening file for writing: " << dataFile << std::endl;
return dataFile;
}
outFile << "Time,Depth(m),Temperature(C),Altitude,Pressure";
return dataFile;
}
};