DDNet documentation
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
34void set_new_tick();
35
43std::chrono::nanoseconds time_get_nanoseconds();
44
56int64_t time_get_impl();
57
71int64_t time_get();
72
78constexpr int64_t time_freq()
79{
80 using namespace std::chrono_literals;
81 return std::chrono::nanoseconds(1s).count();
82}
83
91int64_t time_timestamp();
92
101
118
127
138void 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
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
215
228int64_t time_milliseconds_from_seconds(float seconds);
229
242int str_time(int64_t centisecs, ETimeFormat format, char *buffer, int buffer_size);
243
258int str_time_float(float secs, ETimeFormat format, char *buffer, int buffer_size);
259
260#endif
std::chrono::nanoseconds time_get_nanoseconds()
Definition time.cpp:25
ETimeSeason
Definition time.h:108
void set_new_tick()
Definition time.cpp:16
int time_houroftheday()
Definition time.cpp:67
ETimeSeason time_season()
Definition time.cpp:105
constexpr int64_t time_freq()
Definition time.h:78
int64_t time_get()
Definition time.cpp:35
int64_t time_get_impl()
Definition time.cpp:30
@ NEWYEAR
Definition time.h:116
@ XMAS
Definition time.h:115
@ SPRING
Definition time.h:109
@ EASTER
Definition time.h:113
@ WINTER
Definition time.h:112
@ AUTUMN
Definition time.h:111
@ HALLOWEEN
Definition time.h:114
@ SUMMER
Definition time.h:110
int str_time(int64_t centisecs, ETimeFormat format, char *buffer, int buffer_size)
Definition time.cpp:199
ETimeFormat
Definition time.h:207
bool timestamp_from_str(const char *string, const char *format, time_t *timestamp)
Definition time.cpp:174
int64_t time_milliseconds_from_seconds(float seconds)
Definition time.cpp:194
int64_t time_timestamp()
Definition time.cpp:47
void str_timestamp(char *buffer, int buffer_size)
Definition time.cpp:155
void str_timestamp_format(char *buffer, int buffer_size, const char *format)
Definition time.cpp:160
int str_time_float(float secs, ETimeFormat format, char *buffer, int buffer_size)
Definition time.cpp:243
void str_timestamp_ex(time_t time, char *buffer, int buffer_size, const char *format)
Definition time.cpp:167
@ SECS_CENTISECS
Definition time.h:213
@ HOURS
Definition time.h:209
@ DAYS
Definition time.h:208
@ MINS
Definition time.h:210
@ MINS_CENTISECS
Definition time.h:212
@ HOURS_CENTISECS
Definition time.h:211
static SHA256_DIGEST s(const char *pSha256)
Definition mapbugs.cpp:38
Definition time.h:192
const char *const SPACE
Definition time.h:194
const char *const NOSPACE
Definition time.h:195
const char *const TIME
Definition time.h:193