summaryrefslogtreecommitdiff
path: root/src/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-12-23 01:05:49 +0100
committerCarl Hetherington <cth@carlh.net>2019-12-23 01:05:49 +0100
commit64e72c622be986c7272e938c2d3235c61abef402 (patch)
tree6cece3eee55fd26a79b2aa3c7e618f55258bcefc /src/util.cc
parent2b5af718d2a1f5da548303c8531afe86fa82d2d8 (diff)
Add struct tm constructor for LocalTime, use it to tidy up
day_{greater,less}_than_or_equal and add add_months() method.
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/util.cc b/src/util.cc
index 533ee466..9374b6e7 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -381,34 +381,34 @@ dcp::indent (xmlpp::Element* element, int initial)
* equal to the one represented by \ref b, ignoring the time parts.
*/
bool
-dcp::day_less_than_or_equal (struct tm a, LocalTime b)
+dcp::day_less_than_or_equal (LocalTime a, LocalTime b)
{
- if ((a.tm_year + 1900) != b.year()) {
- return (a.tm_year + 1900) < b.year();
+ if (a.year() != b.year()) {
+ return a.year() < b.year();
}
- if ((a.tm_mon + 1) != b.month()) {
- return (a.tm_mon + 1) < b.month();
+ if (a.month() != b.month()) {
+ return a.month() < b.month();
}
- return a.tm_mday <= b.day();
+ return a.day() <= b.day();
}
/** @return true if the day represented by \ref a is greater than or
* equal to the one represented by \ref b, ignoring the time parts.
*/
bool
-dcp::day_greater_than_or_equal (struct tm a, LocalTime b)
+dcp::day_greater_than_or_equal (LocalTime a, LocalTime b)
{
- if ((a.tm_year + 1900) != b.year()) {
- return (a.tm_year + 1900) > b.year();
+ if (a.year() != b.year()) {
+ return a.year() > b.year();
}
- if ((a.tm_mon + 1) != b.month()) {
- return (a.tm_mon + 1) > b.month();
+ if (a.month() != b.month()) {
+ return a.month() > b.month();
}
- return a.tm_mday >= b.day();
+ return a.day() >= b.day();
}
/** Try quite hard to find a string which starts with \ref base and is