teditor  1.8.0@@fee5e94
Terminal based editor written in C++
time_utils.h
Go to the documentation of this file.
1 #include <ctime>
2 #include <string>
3 #include <chrono>
4 
5 namespace teditor {
6 
7 typedef std::chrono::system_clock::time_point TimePoint;
8 
9 bool operator>(const struct timeval& ta, const struct timeval& tb);
10 
11 struct tm toStructTm(const TimePoint& pt);
12 TimePoint toTimePoint(struct tm& tm_);
13 std::string timeToStr(const TimePoint& pt);
14 std::string timeToDateStr(const TimePoint& pt);
15 std::string currentTimeToStr();
16 TimePoint timeFromStr(const std::string& dt);
17 int dayOfWeek(const TimePoint& pt);
18 int year(const TimePoint& pt);
19 int month(const TimePoint& pt);
20 int day(const TimePoint& pt);
21 
22 void addSecond(TimePoint& pt);
23 void addMinute(TimePoint& pt);
24 void addHour(TimePoint& pt);
25 void addDay(TimePoint& pt, int times);
26 void addWeek(TimePoint& pt, int times);
27 void addMonth(TimePoint& pt);
28 void addYear(TimePoint& pt);
29 
30 TimePoint addSecond(const TimePoint& pt);
31 TimePoint addMinute(const TimePoint& pt);
32 TimePoint addHour(const TimePoint& pt);
33 TimePoint addDay(const TimePoint& pt, int times);
34 TimePoint addWeek(const TimePoint& pt, int times);
35 TimePoint addMonth(const TimePoint& pt);
36 TimePoint addYear(const TimePoint& pt);
37 
38 void weekFor(TimePoint& start, TimePoint& end, const TimePoint& pt);
39 
40 } // namespace teditor
teditor::timeFormat
const std::string & timeFormat()
Definition: time_utils.cpp:17
teditor::timeToDateStr
std::string timeToDateStr(const TimePoint &pt)
Definition: time_utils.cpp:39
teditor::day
int day(const TimePoint &pt)
Definition: time_utils.cpp:78
utils.h
teditor::toStructTm
struct tm toStructTm(const TimePoint &pt)
Definition: time_utils.cpp:22
teditor::addYear
void addYear(TimePoint &pt)
Definition: time_utils.cpp:106
ASSERT
#define ASSERT(check, fmt,...)
Macro to assert with runtime_error exception if the check fails.
Definition: utils.h:35
teditor::TimePoint
std::chrono::system_clock::time_point TimePoint
Definition: time_utils.h:7
teditor::timeToStr
std::string timeToStr(const TimePoint &pt)
Definition: time_utils.cpp:32
teditor::weekFor
void weekFor(TimePoint &start, TimePoint &end, const TimePoint &pt)
Definition: time_utils.cpp:154
teditor::dayOfWeek
int dayOfWeek(const TimePoint &pt)
Definition: time_utils.cpp:66
time_utils.h
teditor::toTimePoint
TimePoint toTimePoint(struct tm &tm_)
Definition: time_utils.cpp:27
teditor::addWeek
void addWeek(TimePoint &pt, int times)
Definition: time_utils.cpp:92
teditor::timeFromStr
TimePoint timeFromStr(const std::string &dt)
Definition: time_utils.cpp:50
teditor::year
int year(const TimePoint &pt)
Definition: time_utils.cpp:70
teditor::operator>
bool operator>(const struct timeval &ta, const struct timeval &tb)
Definition: time_utils.cpp:11
teditor::addMonth
void addMonth(TimePoint &pt)
Definition: time_utils.cpp:96
teditor::addHour
void addHour(TimePoint &pt)
Definition: time_utils.cpp:86
teditor::month
int month(const TimePoint &pt)
Definition: time_utils.cpp:74
teditor::addDay
void addDay(TimePoint &pt, int times)
Definition: time_utils.cpp:88
teditor::addSecond
void addSecond(TimePoint &pt)
Definition: time_utils.cpp:82
teditor
Definition: any.hpp:10
teditor::addMinute
void addMinute(TimePoint &pt)
Definition: time_utils.cpp:84
teditor::currentTimeToStr
std::string currentTimeToStr()
Definition: time_utils.cpp:46