Fixes to times for KDMs.
authorCarl Hetherington <cth@carlh.net>
Thu, 10 Jan 2013 21:54:45 +0000 (21:54 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 10 Jan 2013 21:54:45 +0000 (21:54 +0000)
src/lib/film.cc
src/lib/film.h
src/tools/dvdomatic.cc
src/wx/kdm_dialog.cc
src/wx/kdm_dialog.h

index 1b53b3d3ebe48b6a96e1759df1c1566d4068eb96..012495226656d5920258d80a27641c01e405171d 100644 (file)
@@ -65,6 +65,7 @@ using std::ofstream;
 using std::setfill;
 using std::min;
 using std::make_pair;
+using std::list;
 using std::cout;
 using boost::shared_ptr;
 using boost::lexical_cast;
@@ -1388,8 +1389,8 @@ Film::audio_stream () const
 void
 Film::make_kdms (
        list<shared_ptr<Screen> >,
-       boost::locale::date_time from,
-       boost::locale::date_time until,
+       boost::posix_time::ptime from,
+       boost::posix_time::ptime until,
        string directory
        ) const
 {
index c9d99dae339ad1d705e13b950fe47aff0cb5e95b..b119d59a6e9cb2861b6157c974d13e0c9eeff6c4 100644 (file)
@@ -32,6 +32,7 @@
 #include <boost/thread.hpp>
 #include <boost/signals2.hpp>
 #include <boost/enable_shared_from_this.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
 extern "C" {
 #include <libavcodec/avcodec.h>
 }
@@ -103,10 +104,10 @@ public:
 
        void make_kdms (
                std::list<boost::shared_ptr<Screen> >,
-               boost::locale::date_time from,
-               boost::locale::date_time until,
+               boost::posix_time::ptime from,
+               boost::posix_time::ptime until,
                std::string directory
-               );
+               ) const;
 
        enum Property {
                NONE,
index 7d7adcce839ff4f8e0a623f73cfebd26561e0f33..b6662f281d2f9fa777ead37bc233637aeaf3deb4 100644 (file)
@@ -337,9 +337,13 @@ public:
 
        void jobs_make_kdms (wxCommandEvent &)
        {
+               if (!film) {
+                       return;
+               }
+               
                KDMDialog* d = new KDMDialog (this);
                if (d->ShowModal () == wxID_OK) {
-                       _film->make_kdms (
+                       film->make_kdms (
                                d->screens (),
                                d->from (),
                                d->until (),
index 43d904d90b94dee3560c26a93a529a277c7d7976..0febdf38efa5b3b9f0fc30b025f6c19bb9b09f55 100644 (file)
@@ -329,7 +329,7 @@ KDMDialog::screens () const
 
        list<pair<wxTreeItemId, shared_ptr<Cinema> > > cinemas = selected_cinemas ();
        for (list<pair<wxTreeItemId, shared_ptr<Cinema> > >::iterator i = cinemas.begin(); i != cinemas.end(); ++i) {
-               for (list<Screen>::iterator j = i->second->screens.begin(); j != i->second->screens.end(); ++j) {
+               for (list<shared_ptr<Screen> >::iterator j = i->second->screens.begin(); j != i->second->screens.end(); ++j) {
                        s.push_back (*j);
                }
        }
@@ -340,21 +340,32 @@ KDMDialog::screens () const
        }
 
        s.sort ();
-       s.uniq ();
+       s.unique ();
 
        return s;
 }
 
-boost::locale::date_time
+boost::posix_time::ptime
 KDMDialog::from () const
 {
+       return posix_time (_from_date, _from_time);
+}
 
+boost::posix_time::ptime
+KDMDialog::posix_time (wxDatePickerCtrl* date_picker, wxTimePickerCtrl* time_picker)
+{
+       wxDateTime const date = date_picker->GetValue ();
+       wxDateTime const time = time_picker->GetValue ();
+       return boost::posix_time::ptime (
+               boost::gregorian::date (date.GetYear(), date.GetMonth() + 1, date.GetDay()),
+               boost::posix_time::time_duration (time.GetHour(), time.GetMinute(), time.GetSecond())
+               );
 }
 
-boost::locale::date_time
+boost::posix_time::ptime
 KDMDialog::until () const
 {
-
+       return posix_time (_until_date, _until_time);
 }
 
 string
index d161223a8eab1259a14b62f9dd7af88a831cff72..ac2db9b95bed814f1db5f62abb81b39c2486c5d8 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <map>
 #include <boost/shared_ptr.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
 #include <wx/wx.h>
 #include <wx/treectrl.h>
 
@@ -37,8 +38,8 @@ public:
        KDMDialog (wxWindow *);
 
        std::list<boost::shared_ptr<Screen> > screens () const;
-       boost::local::date_time from () const;
-       boost::local::date_time until () const;
+       boost::posix_time::ptime from () const;
+       boost::posix_time::ptime until () const;
        std::string directory () const;
 
 private:
@@ -54,6 +55,8 @@ private:
        std::list<std::pair<wxTreeItemId, boost::shared_ptr<Cinema> > > selected_cinemas () const;
        std::list<std::pair<wxTreeItemId, boost::shared_ptr<Screen> > > selected_screens () const;
        void setup_sensitivity ();
+
+       static boost::posix_time::ptime posix_time (wxDatePickerCtrl *, wxTimePickerCtrl *);
        
        wxTreeCtrl* _targets;
        wxButton* _add_cinema;