From dd72bed28a2373d1d40432d3c9417e9c71b4f463 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 30 May 2016 14:04:49 -0400 Subject: [PATCH] ISO8601: Added ::sameQuarter --- src/ISO8601.cpp | 7 +++++++ src/ISO8601.h | 31 ++++++++++++++++--------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/ISO8601.cpp b/src/ISO8601.cpp index 2edf511af..8a94621b5 100644 --- a/src/ISO8601.cpp +++ b/src/ISO8601.cpp @@ -1574,6 +1574,13 @@ bool ISO8601d::sameMonth (const ISO8601d& rhs) const this->month () == rhs.month (); } +//////////////////////////////////////////////////////////////////////////////// +bool ISO8601d::sameQuarter (const ISO8601d& rhs) const +{ + return (this->year () == rhs.year ()) && + ((this->month () - 1) / 4) == ((rhs.month () - 1) / 4); +} + //////////////////////////////////////////////////////////////////////////////// bool ISO8601d::sameYear (const ISO8601d& rhs) const { diff --git a/src/ISO8601.h b/src/ISO8601.h index c7b7cd027..b3f82e5aa 100644 --- a/src/ISO8601.h +++ b/src/ISO8601.h @@ -86,26 +86,27 @@ public: int minute () const; int second () const; - bool operator== (const ISO8601d&) const; - bool operator!= (const ISO8601d&) const; - bool operator< (const ISO8601d&) const; - bool operator> (const ISO8601d&) const; - bool operator<= (const ISO8601d&) const; - bool operator>= (const ISO8601d&) const; - bool sameHour (const ISO8601d&) const; - bool sameDay (const ISO8601d&) const; - bool sameWeek (const ISO8601d&) const; - bool sameMonth (const ISO8601d&) const; - bool sameYear (const ISO8601d&) const; + bool operator== (const ISO8601d&) const; + bool operator!= (const ISO8601d&) const; + bool operator< (const ISO8601d&) const; + bool operator> (const ISO8601d&) const; + bool operator<= (const ISO8601d&) const; + bool operator>= (const ISO8601d&) const; + bool sameHour (const ISO8601d&) const; + bool sameDay (const ISO8601d&) const; + bool sameWeek (const ISO8601d&) const; + bool sameMonth (const ISO8601d&) const; + bool sameQuarter (const ISO8601d&) const; + bool sameYear (const ISO8601d&) const; ISO8601d operator+ (const int); ISO8601d operator- (const int); ISO8601d& operator+= (const int); ISO8601d& operator-= (const int); time_t operator- (const ISO8601d&); - void operator-- (); // Prefix - void operator-- (int); // Postfix - void operator++ (); // Prefix - void operator++ (int); // Postfix + void operator-- (); // Prefix + void operator-- (int); // Postfix + void operator++ (); // Prefix + void operator++ (int); // Postfix private: void clear ();