-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdatetime.h
More file actions
30 lines (24 loc) · 790 Bytes
/
datetime.h
File metadata and controls
30 lines (24 loc) · 790 Bytes
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
#pragma once
#include <string>
#include <chrono>
namespace datetime {
std::string to_iso_8601(std::chrono::time_point<std::chrono::system_clock> t = std::chrono::system_clock::now());
std::string human_readable_duration(std::chrono::seconds seconds, bool short_format = true);
/// <summary>
/// Really simple time measure utility.
/// Starts measuring time when constructed. To
/// </summary>
class measure {
public:
measure();
~measure();
/// <summary>
/// Stops measurement and returns number of milliseconds it took.
/// </summary>
long long take();
private:
std::chrono::steady_clock::time_point start_time;
std::chrono::steady_clock::time_point end_time;
std::chrono::nanoseconds duration;
};
}