forked from sourcesimian/uICAL
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtzmap.cpp
More file actions
76 lines (65 loc) · 1.99 KB
/
Copy pathtzmap.cpp
File metadata and controls
76 lines (65 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*############################################################################
# Copyright (c) 2020 Source Simian : https://github.com/sourcesimian/uICAL #
############################################################################*/
#include "uICAL/cppstl.h"
#include "uICAL/types.h"
#include "uICAL/tzmap.h"
#include "uICAL/tz.h"
#include "uICAL/vline.h"
#include "uICAL/vobject.h"
namespace uICAL
{
TZMap::TZMap()
{
this->add("Z", "Z", tz_UTC);
}
void TZMap::add(const VObject_ptr &timezone)
{
string tzId = timezone->getPropertyByName("TZID")->value;
auto standards = timezone->listObjects("STANDARD");
for (auto standard : standards)
{
string offset = standard->getPropertyByName("TZOFFSETFROM")->value;
string name = standard->getPropertyByName("TZNAME")->value;
this->add(tzId, name, offset);
}
}
void TZMap::add(const string &id, const string &name, const string &tz)
{
this->id_attrib_map[id].tz = new_ptr<OffsetTZ>(name, tz);
this->id_attrib_map[id].name = name;
}
void TZMap::add(const string &id, const string &name, const TZ_ptr tz)
{
this->id_attrib_map[id].tz = tz;
this->id_attrib_map[id].name = name;
}
const TZ_ptr TZMap::getTZ(const string &tzId)
{
return this->id_attrib_map[tzId].tz;
}
string TZMap::getName(const string &tzId)
{
return this->id_attrib_map[tzId].name;
}
const TZ_ptr TZMap::get_by_name(const string &name) const
{
for (auto &it : this->id_attrib_map)
{
if (it.second.name == name)
{
return it.second.tz;
}
}
return nullptr;
}
void TZMap::str(ostream &out) const
{
for (auto i : this->id_attrib_map)
{
out << i.first << " : " << i.second.name << " : ";
i.second.tz->output_details(out);
out << uICAL::endl;
}
}
}