Add UTC-3:30 timezone to cinema (#831).
authorCarl Hetherington <cth@carlh.net>
Mon, 11 Apr 2016 12:05:00 +0000 (13:05 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 11 Apr 2016 12:05:00 +0000 (13:05 +0100)
ChangeLog
src/lib/cinema.cc
src/lib/cinema.h
src/lib/film.cc
src/tools/dcpomatic_kdm.cc
src/wx/cinema_dialog.cc
src/wx/cinema_dialog.h
src/wx/screens_panel.cc

index 0c60df9caac717ff94f43b78778579649f1b578d..a5c68e7764b5b7777c7d3c47f9228b189b9e3b54 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2016-04-11  Carl Hetherington  <cth@carlh.net>
 
+       * Add UTC-3:30 timezone to Cinema configuration (#831).
+
        * Add option to preview left or right eye (#809).
 
 2016-04-09  Carl Hetherington  <cth@carlh.net>
index 5e2b1b533bb49df0926844c15366fec3ff88e063..e9a7dce6882e08f52722e7733ea05071d6b88443 100644 (file)
@@ -32,11 +32,18 @@ using boost::shared_ptr;
 
 Cinema::Cinema (cxml::ConstNodePtr node)
        : name (node->string_child ("Name"))
-       , _utc_offset (node->optional_number_child<int>("UTCOffset").get_value_or (0))
 {
        BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Email")) {
                emails.push_back (i->content ());
        }
+
+       if (node->optional_number_child<int>("UTCOffset")) {
+               _utc_offset_hour = node->number_child<int>("UTCOffset");
+       } else {
+               _utc_offset_hour = node->optional_number_child<int>("UTCOffsetHour").get_value_or (0);
+       }
+
+       _utc_offset_minute = node->optional_number_child<int>("UTCOffsetMinute").get_value_or (0);
 }
 
 /* This is necessary so that we can use shared_from_this in add_screen (which cannot be done from
@@ -60,7 +67,8 @@ Cinema::as_xml (xmlpp::Element* parent) const
                parent->add_child("Email")->add_child_text (i);
        }
 
-       parent->add_child("UTCOffset")->add_child_text (dcp::raw_convert<string> (_utc_offset));
+       parent->add_child("UTCOffsetHour")->add_child_text (dcp::raw_convert<string> (_utc_offset_hour));
+       parent->add_child("UTCOffsetMinute")->add_child_text (dcp::raw_convert<string> (_utc_offset_minute));
 
        BOOST_FOREACH (shared_ptr<Screen> i, _screens) {
                i->as_xml (parent->add_child ("Screen"));
@@ -81,8 +89,15 @@ Cinema::remove_screen (shared_ptr<Screen> s)
 }
 
 void
-Cinema::set_utc_offset (int o)
+Cinema::set_utc_offset_hour (int h)
+{
+       DCPOMATIC_ASSERT (h >= -11 && h <= 12);
+       _utc_offset_hour = h;
+}
+
+void
+Cinema::set_utc_offset_minute (int m)
 {
-       DCPOMATIC_ASSERT (o >= -11 && o <= 12);
-       _utc_offset = o;
+       DCPOMATIC_ASSERT (m >= 0 && m <= 59);
+       _utc_offset_minute = m;
 }
index 7df83c7678f2c4c40ef9751707d20908917a6966..70508f23321d4a233e7bed4ffc8d62ef095d2eff 100644 (file)
@@ -39,10 +39,11 @@ class Screen;
 class Cinema : public boost::enable_shared_from_this<Cinema>
 {
 public:
-       Cinema (std::string const & n, std::list<std::string> const & e, int utc_offset)
+       Cinema (std::string const & n, std::list<std::string> const & e, int utc_offset_hour, int utc_offset_minute)
                : name (n)
                , emails (e)
-               , _utc_offset (utc_offset)
+               , _utc_offset_hour (utc_offset_hour)
+               , _utc_offset_minute (utc_offset_minute)
        {}
 
        Cinema (cxml::ConstNodePtr);
@@ -54,13 +55,20 @@ public:
        void add_screen (boost::shared_ptr<Screen>);
        void remove_screen (boost::shared_ptr<Screen>);
 
-       void set_utc_offset (int o);
+       void set_utc_offset_hour (int h);
+       void set_utc_offset_minute (int m);
 
        std::string name;
        std::list<std::string> emails;
-       int utc_offset () const {
-               return _utc_offset;
+
+       int utc_offset_hour () const {
+               return _utc_offset_hour;
+       }
+
+       int utc_offset_minute () const {
+               return _utc_offset_minute;
        }
+
        std::list<boost::shared_ptr<Screen> > screens () const {
                return _screens;
        }
@@ -70,5 +78,9 @@ private:
        /** Offset such that the equivalent time in UTC can be determined
            by subtracting the offset from the local time.
        */
-       int _utc_offset;
+       int _utc_offset_hour;
+       /** Additional minutes to add to _utc_offset_hour if _utc_offset_hour is
+           positive, or to subtract if _utc_offset_hour is negative.
+       */
+       int _utc_offset_minute;
 };
index e669ea4ae434a2f8d08cdbb0b0aca78370d9f86e..1775f7c7f94e2a3efa0ecffe851f363f9ff32580 100644 (file)
@@ -1208,8 +1208,8 @@ Film::make_kdms (
                                i->recipient.get(),
                                i->trusted_devices,
                                dcp,
-                               dcp::LocalTime (from, i->cinema->utc_offset(), 0),
-                               dcp::LocalTime (until, i->cinema->utc_offset(), 0),
+                               dcp::LocalTime (from, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()),
+                               dcp::LocalTime (until, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()),
                                formulation
                                );
 
index 6c3103da2219d5f6b9831aeb4fdceddad6be8a67..3f156f4b9ece9fbdbe131cfdc69ed2c131472966 100644 (file)
@@ -271,8 +271,8 @@ private:
 
                                /* Make an empty KDM */
                                dcp::DecryptedKDM kdm (
-                                       dcp::LocalTime (_timing->from(), i->cinema->utc_offset(), 0),
-                                       dcp::LocalTime (_timing->until(), i->cinema->utc_offset(), 0),
+                                       dcp::LocalTime (_timing->from(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()),
+                                       dcp::LocalTime (_timing->until(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()),
                                        decrypted.annotation_text(),
                                        decrypted.content_title_text(),
                                        dcp::LocalTime().as_string()
index c0b7b5242837947da86d3c682b36d331abc66a1b..b4663195f27ab9438a39af4b00cd41a0c197e803 100644 (file)
@@ -37,7 +37,7 @@ column (string s)
        return s;
 }
 
-CinemaDialog::CinemaDialog (wxWindow* parent, string title, string name, list<string> emails, int utc_offset)
+CinemaDialog::CinemaDialog (wxWindow* parent, string title, string name, list<string> emails, int utc_offset_hour, int utc_offset_minute)
        : wxDialog (parent, wxID_ANY, std_to_wx (title))
 {
        wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
@@ -77,15 +77,41 @@ CinemaDialog::CinemaDialog (wxWindow* parent, string title, string name, list<st
                overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
        }
 
-       for (int i = -11; i <= -1; ++i) {
-               _utc_offset->Append (wxString::Format (_("UTC%d"), i));
-       }
-       _utc_offset->Append (_("UTC"));
-       for (int i = 1; i <= 12; ++i) {
-               _utc_offset->Append (wxString::Format (_("UTC+%d"), i));
+       _offsets.push_back (Offset (_("UTC-11"),  -11,  0));
+       _offsets.push_back (Offset (_("UTC-10"),  -10,  0));
+       _offsets.push_back (Offset (_("UTC-9"),    -9,  0));
+       _offsets.push_back (Offset (_("UTC-8"),    -8,  0));
+       _offsets.push_back (Offset (_("UTC-7"),    -7,  0));
+       _offsets.push_back (Offset (_("UTC-6"),    -6,  0));
+       _offsets.push_back (Offset (_("UTC-5"),    -5,  0));
+       _offsets.push_back (Offset (_("UTC-4"),    -4,  0));
+       _offsets.push_back (Offset (_("UTC-3:30"), -3, 30));
+       _offsets.push_back (Offset (_("UTC-3"),    -3,  0));
+       _offsets.push_back (Offset (_("UTC-2"),    -2,  0));
+       _offsets.push_back (Offset (_("UTC-1"),    -1,  0));
+       _offsets.push_back (Offset (_("UTC")  ,     0,  0));
+       _offsets.push_back (Offset (_("UTC+1"),     1,  0));
+       _offsets.push_back (Offset (_("UTC+2"),     2,  0));
+       _offsets.push_back (Offset (_("UTC+3"),     3,  0));
+       _offsets.push_back (Offset (_("UTC+4"),     4,  0));
+       _offsets.push_back (Offset (_("UTC+5"),     5,  0));
+       _offsets.push_back (Offset (_("UTC+6"),     6,  0));
+       _offsets.push_back (Offset (_("UTC+7"),     7,  0));
+       _offsets.push_back (Offset (_("UTC+8"),     8,  0));
+       _offsets.push_back (Offset (_("UTC+9"),     9,  0));
+       _offsets.push_back (Offset (_("UTC+10"),   10,  0));
+       _offsets.push_back (Offset (_("UTC+11"),   11,  0));
+       _offsets.push_back (Offset (_("UTC+12"),   12,  0));
+
+       size_t sel;
+       for (size_t i = 0; i < _offsets.size(); ++i) {
+               _utc_offset->Append (_offsets[i].name);
+               if (_offsets[i].hour == utc_offset_hour && _offsets[i].minute == utc_offset_minute) {
+                       sel = i;
+               }
        }
 
-       _utc_offset->SetSelection (utc_offset + 11);
+       _utc_offset->SetSelection (sel);
 
        overall_sizer->Layout ();
        overall_sizer->SetSizeHints (this);
@@ -118,7 +144,23 @@ CinemaDialog::emails () const
 }
 
 int
-CinemaDialog::utc_offset () const
+CinemaDialog::utc_offset_hour () const
 {
-       return _utc_offset->GetSelection() - 11;
+       size_t const sel =  _utc_offset->GetSelection();
+       if (sel < 0 || sel > _offsets.size()) {
+               return 0;
+       }
+
+       return _offsets[sel].hour;
+}
+
+int
+CinemaDialog::utc_offset_minute () const
+{
+       size_t const sel =  _utc_offset->GetSelection();
+       if (sel < 0 || sel > _offsets.size()) {
+               return 0;
+       }
+
+       return _offsets[sel].minute;
 }
index a34935e51274193a1fcfa9399ed11fb7969fda66..2949d6c8c3eb27412ae004af159087923709a818 100644 (file)
 class CinemaDialog : public wxDialog
 {
 public:
-       CinemaDialog (wxWindow *, std::string, std::string name = "", std::list<std::string> emails = std::list<std::string> (), int utc_offset = 0);
+       CinemaDialog (
+               wxWindow *,
+               std::string,
+               std::string name = "",
+               std::list<std::string> emails = std::list<std::string> (),
+               int utc_offset_hour = 0,
+               int utc_offset_minute = 0
+               );
 
        std::string name () const;
        std::list<std::string> emails () const;
-       int utc_offset () const;
+       int utc_offset_hour () const;
+       int utc_offset_minute () const;
 
 private:
        std::vector<std::string> get_emails () const;
@@ -41,4 +49,19 @@ private:
        EditableList<std::string, EmailDialog>* _email_list;
        std::vector<std::string> _emails;
        wxChoice* _utc_offset;
+
+       struct Offset
+       {
+               Offset (wxString n, int h, int m)
+                       : name (n)
+                       , hour (h)
+                       , minute (m)
+               {}
+
+               wxString name;
+               int hour;
+               int minute;
+       };
+
+       std::vector<Offset> _offsets;
 };
index a75316d8cc7bcede0992e649e9bd837b30e7a638..ddb088c2fcf2564de5b05493ab5a225c109cef92 100644 (file)
@@ -149,7 +149,7 @@ ScreensPanel::add_cinema_clicked ()
 {
        CinemaDialog* d = new CinemaDialog (this, "Add Cinema");
        if (d->ShowModal () == wxID_OK) {
-               shared_ptr<Cinema> c (new Cinema (d->name(), d->emails(), d->utc_offset()));
+               shared_ptr<Cinema> c (new Cinema (d->name(), d->emails(), d->utc_offset_hour(), d->utc_offset_minute()));
                Config::instance()->add_cinema (c);
                add_cinema (c);
        }
@@ -166,11 +166,12 @@ ScreensPanel::edit_cinema_clicked ()
 
        pair<wxTreeItemId, shared_ptr<Cinema> > c = *_selected_cinemas.begin();
 
-       CinemaDialog* d = new CinemaDialog (this, "Edit cinema", c.second->name, c.second->emails, c.second->utc_offset());
+       CinemaDialog* d = new CinemaDialog (this, "Edit cinema", c.second->name, c.second->emails, c.second->utc_offset_hour(), c.second->utc_offset_minute());
        if (d->ShowModal () == wxID_OK) {
                c.second->name = d->name ();
                c.second->emails = d->emails ();
-               c.second->set_utc_offset (d->utc_offset ());
+               c.second->set_utc_offset_hour (d->utc_offset_hour ());
+               c.second->set_utc_offset_minute (d->utc_offset_minute ());
                _targets->SetItemText (c.first, std_to_wx (d->name()));
                Config::instance()->changed ();
        }