Ticket #2104 (closed: fixed)
DateAndTime class needs friend function
Reported by: | Peter Peterson | Owned by: | Janik Zikovsky |
---|---|---|---|
Priority: | major | Milestone: | Iteration 27 |
Component: | Mantid | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Tester: | Nick Draper |
Description
To allow for easier simple debugging (i.e. print statements), DateAndTime should have a friend method for std::ostream that prints to_ISO8601_string(). The function declaration should be something like:
friend ostream & operator<<( ostream & os, const DateAndTime obj);
Change History
comment:2 Changed 10 years ago by Janik Zikovsky
It already has an << operator that prints a simple string - is that good enough?
void test_stream_operator() { DateAndTime a; std::ostringstream message; a = DateAndTime("1990-01-02 03:04:05.678"); message << a; TS_ASSERT_EQUALS( message.str(), a.to_simple_string() ); }
comment:3 Changed 10 years ago by Janik Zikovsky
P.S. example above prints 1990-Jan-02 03:04:05.678000000
comment:4 Changed 10 years ago by Peter Peterson
I missed that at the end of the file.
It needs to be declared a friend so it can be called from anywhere.
comment:5 Changed 10 years ago by Janik Zikovsky
- Status changed from accepted to verify
- Resolution set to fixed
Fixed in revision [8220]
Note: See
TracTickets for help on using
tickets.