Restore time zone to Cinema and improve UI to use it (#2473).
[dcpomatic.git] / src / lib / cinema.cc
index 7388dbc2fb890390a15ca75f9f5beead2f956a20..b1681fc2833af14cda3c5a9251f9cb38ff6a3d73 100644 (file)
@@ -41,6 +41,18 @@ Cinema::Cinema (cxml::ConstNodePtr node)
        for (auto i: node->node_children("Email")) {
                emails.push_back (i->content ());
        }
+
+       int hour = 0;
+
+       if (node->optional_number_child<int>("UTCOffset")) {
+               hour = node->number_child<int>("UTCOffset");
+       } else {
+               hour = node->optional_number_child<int>("UTCOffsetHour").get_value_or(0);
+       }
+
+       int minute = node->optional_number_child<int>("UTCOffsetMinute").get_value_or(0);
+
+       utc_offset= { hour, minute };
 }
 
 /* This is necessary so that we can use shared_from_this in add_screen (which cannot be done from
@@ -57,16 +69,19 @@ Cinema::read_screens (cxml::ConstNodePtr node)
 void
 Cinema::as_xml (xmlpp::Element* parent) const
 {
-       parent->add_child("Name")->add_child_text (name);
+       cxml::add_text_child(parent, "Name", name);
 
        for (auto i: emails) {
-               parent->add_child("Email")->add_child_text (i);
+               cxml::add_text_child(parent, "Email", i);
        }
 
-       parent->add_child("Notes")->add_child_text (notes);
+       cxml::add_text_child(parent, "Notes", notes);
+
+       cxml::add_text_child(parent, "UTCOffsetHour", raw_convert<string>(utc_offset.hour()));
+       cxml::add_text_child(parent, "UTCOffsetMinute", raw_convert<string>(utc_offset.minute()));
 
        for (auto i: _screens) {
-               i->as_xml (parent->add_child ("Screen"));
+               i->as_xml(cxml::add_child(parent, "Screen"));
        }
 }