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>
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
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"));
}
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;
}
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);
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;
}
/** 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;
};
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
);
/* 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()
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);
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);
}
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;
}
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;
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;
};
{
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);
}
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 ();
}