Skip to content

Commit 0ef75aa

Browse files
committed
enable adding timezones through pini
1 parent 6b27f33 commit 0ef75aa

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/main.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <cassert>
2+
#include <filesystem>
23
#include <iostream>
34
#include <set>
45
#include <context.hpp>
@@ -8,6 +9,7 @@
89
#include <pini/pini.hpp>
910
#include <world_clock/gui.hpp>
1011
#include <world_clock/io.hpp>
12+
#include "world_clock/world_clock.hpp"
1113

1214
using namespace misc;
1315

@@ -111,13 +113,21 @@ class clock_ticker_t {
111113
};
112114
} // namespace
113115

116+
bool load_timezones(std::filesystem::path const& filename, world_clock_t& clock) {
117+
pn::pini timezones;
118+
if (!timezones.load_file(filename)) { return false; }
119+
120+
for (auto& pair : timezones) {
121+
std::cout << pair.first << " " << pair.second << '\n';
122+
clock.add(pair.first, 0xff8800ff, timezones.get_double(pair.first));
123+
}
124+
return true;
125+
}
114126
int main() {
115127
misc::context_t ctx("World Clock");
116128
ctx.setVerticalSyncEnabled(true);
117129
world_clock_t clock;
118-
clock.add("PDT", 0xff8800ff, -7.0f);
119-
clock.add("IST", 0x44ddffff, 5.5f);
120-
clock.add("CET", 0x11ee44ff, 2.0f);
130+
load_timezones("src/timezones.pini", clock);
121131
std::cout << clock << '\n';
122132
input_t input;
123133
delta_time_t dt;

src/timezones.pini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
GMT=0
2+
ECT=1
3+
EET=2
4+
MET=3
5+
IST=5.3
6+
PST=-8
7+
EST=-5
8+

0 commit comments

Comments
 (0)