Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refs #5139. Added explicit assignment operator to DateAndTime.

  • Loading branch information...
commit 1a7774023a3abda53808d0f51cdb195722ef8ae9 1 parent a0ecde9
@peterfpeterson peterfpeterson authored
View
4 Code/Mantid/Framework/Kernel/inc/MantidKernel/DateAndTime.h
@@ -34,6 +34,7 @@ class MANTID_KERNEL_DLL DateAndTime
{
public:
explicit DateAndTime();
+ DateAndTime(const DateAndTime & rhs);
DateAndTime(const int64_t total_nanoseconds);
explicit DateAndTime(const double seconds, const double nanoseconds);
explicit DateAndTime(const int32_t seconds, const int32_t nanoseconds);
@@ -41,6 +42,9 @@ class MANTID_KERNEL_DLL DateAndTime
DateAndTime(const std::string ISO8601_string);
DateAndTime(const boost::posix_time::ptime _ptime);
+ DateAndTime& operator=(const DateAndTime& rhs);
+ DateAndTime& operator=(const DateAndTime* rhs);
+
void set_from_ptime(boost::posix_time::ptime _ptime);
boost::posix_time::ptime to_ptime() const;
View
24 Code/Mantid/Framework/Kernel/src/DateAndTime.cpp
@@ -138,6 +138,10 @@ time_t utc_mktime(struct tm *utctime)
DateAndTime::DateAndTime() : _nanoseconds(0)
{}
+/** Copy constructor */
+DateAndTime::DateAndTime(const DateAndTime & rhs) : _nanoseconds(rhs._nanoseconds)
+{}
+
//------------------------------------------------------------------------------------------------
/** Construct a date from nanoseconds.
* @param total_nanoseconds :: nanoseconds since Jan 1, 1990 (our epoch).
@@ -223,6 +227,26 @@ DateAndTime::DateAndTime(const int32_t seconds, const int32_t nanoseconds)
_nanoseconds = static_cast<int64_t>(seconds * 1000000000LL + nanoseconds);
}
+/**
+ * @param rhs The object to copy data from.
+ * @return This pointer.
+ */
+DateAndTime& DateAndTime::operator=(const DateAndTime& rhs)
+{
+ this->_nanoseconds = rhs._nanoseconds;
+ return *this;
+}
+
+/**
+ * @param rhs The object to copy data from.
+ * @return This pointer.
+ */
+DateAndTime& DateAndTime::operator=(const DateAndTime* rhs)
+{
+ this->_nanoseconds = rhs->_nanoseconds;
+ return *this;
+}
+
//===========================================================================================
//===========================================================================================
Please sign in to comment.
Something went wrong with that request. Please try again.