summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dcp_time.cc24
-rw-r--r--src/dcp_time.h1
-rw-r--r--src/subtitle_asset.cc4
-rw-r--r--src/subtitle_asset.h2
4 files changed, 11 insertions, 20 deletions
diff --git a/src/dcp_time.cc b/src/dcp_time.cc
index 9b93391b..428215cb 100644
--- a/src/dcp_time.cc
+++ b/src/dcp_time.cc
@@ -99,23 +99,7 @@ libdcp::operator!= (Time const & a, Time const & b)
bool
libdcp::operator<= (Time const & a, Time const & b)
{
- if (a.h != b.h) {
- return a.h <= b.h;
- }
-
- if (a.m != b.m) {
- return a.m <= b.m;
- }
-
- if (a.s != b.s) {
- return a.s <= b.s;
- }
-
- if (a.t != b.t) {
- return a.t <= b.t;
- }
-
- return true;
+ return a < b || a == b;
}
bool
@@ -162,6 +146,12 @@ libdcp::operator> (Time const & a, Time const & b)
return true;
}
+bool
+libdcp::operator>= (Time const & a, Time const & b)
+{
+ return a == b || a > b;
+}
+
ostream &
libdcp::operator<< (ostream& s, Time const & t)
{
diff --git a/src/dcp_time.h b/src/dcp_time.h
index 92cee9a0..a8e7c90c 100644
--- a/src/dcp_time.h
+++ b/src/dcp_time.h
@@ -78,6 +78,7 @@ extern bool operator!= (Time const & a, Time const & b);
extern bool operator<= (Time const & a, Time const & b);
extern bool operator< (Time const & a, Time const & b);
extern bool operator> (Time const & a, Time const & b);
+extern bool operator>= (Time const & a, Time const & b);
extern std::ostream & operator<< (std::ostream & s, Time const & t);
extern Time operator+ (Time a, Time const & b);
extern Time operator- (Time a, Time const & b);
diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc
index 89269fb0..acd40e9b 100644
--- a/src/subtitle_asset.cc
+++ b/src/subtitle_asset.cc
@@ -216,11 +216,11 @@ SubtitleAsset::maybe_add_subtitle (string text, ParseState const & parse_state)
}
list<shared_ptr<Subtitle> >
-SubtitleAsset::subtitles_at (Time t) const
+SubtitleAsset::subtitles_during (Time from, Time to) const
{
list<shared_ptr<Subtitle> > s;
for (list<shared_ptr<Subtitle> >::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
- if ((*i)->in() <= t && t <= (*i)->out ()) {
+ if ((*i)->out() >= from && (*i)->in() <= to) {
s.push_back (*i);
}
}
diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h
index 3dfbe7e2..1571e569 100644
--- a/src/subtitle_asset.h
+++ b/src/subtitle_asset.h
@@ -154,7 +154,7 @@ public:
return _language;
}
- std::list<boost::shared_ptr<Subtitle> > subtitles_at (Time t) const;
+ std::list<boost::shared_ptr<Subtitle> > subtitles_during (Time from, Time to) const;
std::list<boost::shared_ptr<Subtitle> > const & subtitles () const {
return _subtitles;
}