From 401da185ca664fc8d819fc842ffc08e14d4f6486 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 24 Apr 2024 01:49:09 +0200 Subject: Restore time zone to Cinema and improve UI to use it (#2473). --- src/lib/cinema.cc | 15 +++++++++++++++ src/lib/cinema.h | 5 ++++- src/lib/kdm_cli.cc | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/cinema.cc b/src/lib/cinema.cc index 6bd063733..b1681fc28 100644 --- a/src/lib/cinema.cc +++ b/src/lib/cinema.cc @@ -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("UTCOffset")) { + hour = node->number_child("UTCOffset"); + } else { + hour = node->optional_number_child("UTCOffsetHour").get_value_or(0); + } + + int minute = node->optional_number_child("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 @@ -65,6 +77,9 @@ Cinema::as_xml (xmlpp::Element* parent) const cxml::add_text_child(parent, "Notes", notes); + cxml::add_text_child(parent, "UTCOffsetHour", raw_convert(utc_offset.hour())); + cxml::add_text_child(parent, "UTCOffsetMinute", raw_convert(utc_offset.minute())); + for (auto i: _screens) { i->as_xml(cxml::add_child(parent, "Screen")); } diff --git a/src/lib/cinema.h b/src/lib/cinema.h index 7008659d7..05f6fb7fc 100644 --- a/src/lib/cinema.h +++ b/src/lib/cinema.h @@ -23,6 +23,7 @@ */ +#include #include #include @@ -44,10 +45,11 @@ namespace dcpomatic { class Cinema : public std::enable_shared_from_this { public: - Cinema(std::string const & name_, std::vector const & e, std::string notes_) + Cinema(std::string const & name_, std::vector const & e, std::string notes_, dcp::UTCOffset utc_offset_) : name (name_) , emails (e) , notes (notes_) + , utc_offset(std::move(utc_offset_)) {} explicit Cinema (cxml::ConstNodePtr); @@ -62,6 +64,7 @@ public: std::string name; std::vector emails; std::string notes; + dcp::UTCOffset utc_offset; std::vector> screens() const { return _screens; diff --git a/src/lib/kdm_cli.cc b/src/lib/kdm_cli.cc index c442cacdc..21e8c75d3 100644 --- a/src/lib/kdm_cli.cc +++ b/src/lib/kdm_cli.cc @@ -567,7 +567,7 @@ try (for lookup) and by creating a Cinema which the next Screen will be added to. */ cinema_name = optarg; - cinema = make_shared(optarg, vector(), ""); + cinema = make_shared(optarg, vector(), "", dcp::UTCOffset()); break; case 'S': /* Similarly, this could be the name of a new (temporary) screen or the name of a screen -- cgit v1.2.3