DDNet documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
time.h
Go to the documentation of this file.
1
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2
/* If you are missing that file, acquire a complete release at teeworlds.com. */
3
4
#ifndef BASE_TIME_H
5
#define BASE_TIME_H
6
7
#include <chrono>
8
#include <cstdint>
9
#include <ctime>
10
18
26
34
void
set_new_tick
();
35
43
std::chrono::nanoseconds
time_get_nanoseconds
();
44
56
int64_t
time_get_impl
();
57
71
int64_t
time_get
();
72
78
constexpr
int64_t
time_freq
()
79
{
80
using namespace
std::chrono_literals;
81
return
std::chrono::nanoseconds(1s).count();
82
}
83
91
int64_t
time_timestamp
();
92
100
int
time_houroftheday
();
101
107
enum class
ETimeSeason
108
{
109
SPRING
,
110
SUMMER
,
111
AUTUMN
,
112
WINTER
,
113
EASTER
,
114
HALLOWEEN
,
115
XMAS
,
116
NEWYEAR
,
117
};
118
126
ETimeSeason
time_season
();
127
138
void
str_timestamp
(
char
*buffer,
int
buffer_size);
139
152
[[gnu::format(strftime, 3, 0)]]
void
str_timestamp_format
(
char
*buffer,
int
buffer_size,
const
char
*format);
153
167
[[gnu::format(strftime, 4, 0)]]
void
str_timestamp_ex
(time_t time,
char
*buffer,
int
buffer_size,
const
char
*format);
168
180
[[gnu::format(strftime, 2, 0)]]
bool
timestamp_from_str
(
const
char
*
string
,
const
char
*format, time_t *timestamp);
181
191
namespace
TimestampFormat
192
{
193
inline
const
char
*
const
TIME
=
"%H:%M:%S"
;
194
inline
const
char
*
const
SPACE
=
"%Y-%m-%d %H:%M:%S"
;
195
inline
const
char
*
const
NOSPACE
=
"%Y-%m-%d_%H-%M-%S"
;
196
}
197
206
enum class
ETimeFormat
207
{
208
DAYS
,
209
HOURS
,
210
MINS
,
211
HOURS_CENTISECS
,
212
MINS_CENTISECS
,
213
SECS_CENTISECS
,
214
};
215
228
int64_t
time_milliseconds_from_seconds
(
float
seconds);
229
242
int
str_time
(int64_t centisecs,
ETimeFormat
format,
char
*buffer,
int
buffer_size);
243
258
int
str_time_float
(
float
secs,
ETimeFormat
format,
char
*buffer,
int
buffer_size);
259
260
#endif
time_get_nanoseconds
std::chrono::nanoseconds time_get_nanoseconds()
Definition
time.cpp:25
ETimeSeason
ETimeSeason
Definition
time.h:108
set_new_tick
void set_new_tick()
Definition
time.cpp:16
time_houroftheday
int time_houroftheday()
Definition
time.cpp:67
time_season
ETimeSeason time_season()
Definition
time.cpp:105
time_freq
constexpr int64_t time_freq()
Definition
time.h:78
time_get
int64_t time_get()
Definition
time.cpp:35
time_get_impl
int64_t time_get_impl()
Definition
time.cpp:30
ETimeSeason::NEWYEAR
@ NEWYEAR
Definition
time.h:116
ETimeSeason::XMAS
@ XMAS
Definition
time.h:115
ETimeSeason::SPRING
@ SPRING
Definition
time.h:109
ETimeSeason::EASTER
@ EASTER
Definition
time.h:113
ETimeSeason::WINTER
@ WINTER
Definition
time.h:112
ETimeSeason::AUTUMN
@ AUTUMN
Definition
time.h:111
ETimeSeason::HALLOWEEN
@ HALLOWEEN
Definition
time.h:114
ETimeSeason::SUMMER
@ SUMMER
Definition
time.h:110
str_time
int str_time(int64_t centisecs, ETimeFormat format, char *buffer, int buffer_size)
Definition
time.cpp:199
ETimeFormat
ETimeFormat
Definition
time.h:207
timestamp_from_str
bool timestamp_from_str(const char *string, const char *format, time_t *timestamp)
Definition
time.cpp:174
time_milliseconds_from_seconds
int64_t time_milliseconds_from_seconds(float seconds)
Definition
time.cpp:194
time_timestamp
int64_t time_timestamp()
Definition
time.cpp:47
str_timestamp
void str_timestamp(char *buffer, int buffer_size)
Definition
time.cpp:155
str_timestamp_format
void str_timestamp_format(char *buffer, int buffer_size, const char *format)
Definition
time.cpp:160
str_time_float
int str_time_float(float secs, ETimeFormat format, char *buffer, int buffer_size)
Definition
time.cpp:243
str_timestamp_ex
void str_timestamp_ex(time_t time_data, char *buffer, int buffer_size, const char *format)
Definition
time.cpp:167
ETimeFormat::SECS_CENTISECS
@ SECS_CENTISECS
Definition
time.h:213
ETimeFormat::HOURS
@ HOURS
Definition
time.h:209
ETimeFormat::DAYS
@ DAYS
Definition
time.h:208
ETimeFormat::MINS
@ MINS
Definition
time.h:210
ETimeFormat::MINS_CENTISECS
@ MINS_CENTISECS
Definition
time.h:212
ETimeFormat::HOURS_CENTISECS
@ HOURS_CENTISECS
Definition
time.h:211
TimestampFormat
Definition
time.h:192
TimestampFormat::SPACE
const char *const SPACE
Definition
time.h:194
TimestampFormat::NOSPACE
const char *const NOSPACE
Definition
time.h:195
TimestampFormat::TIME
const char *const TIME
Definition
time.h:193
src
base
time.h
Generated by
1.18.0