Mercurial > minori
annotate include/core/time.h @ 347:a0aa8c8c4307
dep/anitomy: port to use UCS-4 rather than wide strings
rationale: wide strings are not the same on every platform, and
might not even be Unicode. (while they usually are, its possible
that they are not)
I was *going* to change StringToInt to use a string stream, but
outputting to an integer doesn't seem to work at all with UCS-4,
even though it ought to, so I just rolled my own that uses the
arabic digits only.
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sun, 23 Jun 2024 10:32:09 -0400 |
parents | d928ec7b6a0d |
children |
rev | line source |
---|---|
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
1 #ifndef MINORI_CORE_TIME_H_ |
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
2 #define MINORI_CORE_TIME_H_ |
85 | 3 |
9 | 4 #include <cstdint> |
5 #include <string> | |
6 namespace Time { | |
7 | |
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
8 /* this is in SECONDS */ |
308 | 9 using Timestamp = int64_t; |
9 | 10 |
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
11 enum class Units { |
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
12 Seconds, |
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
13 Minutes |
9 | 14 }; |
15 | |
305
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
16 std::string GetSecondsAsRelativeString(Timestamp length); |
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
17 std::string GetSecondsAsAbsoluteString(Units unit_cutoff, Timestamp amount, double unit_in_seconds = 1.0); |
91ac90a34003
core/time: remove Duration class, use regular functions instead
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
18 |
308 | 19 /* in UTC */ |
20 Timestamp GetSystemTime(); | |
9 | 21 |
319
d928ec7b6a0d
services/kitsu: implement GetAnimeList()
Paper <paper@paper.us.eu.org>
parents:
308
diff
changeset
|
22 Timestamp ParseISO8601Time(const std::string& str); |
d928ec7b6a0d
services/kitsu: implement GetAnimeList()
Paper <paper@paper.us.eu.org>
parents:
308
diff
changeset
|
23 |
85 | 24 }; // namespace Time |
25 | |
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
26 #endif // MINORI_CORE_TIME_H_ |