C++ Utilities  4.17.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
format.h
Go to the documentation of this file.
1 #ifndef CHRONO_FORMAT_H
2 #define CHRONO_FORMAT_H
3 
4 #include "./datetime.h"
5 #include "./period.h"
6 
7 #include <ostream>
8 
9 inline std::ostream &operator<<(std::ostream &out, const ChronoUtilities::DateTime &value)
10 {
12 }
13 
14 inline std::ostream &operator<<(std::ostream &out, const ChronoUtilities::TimeSpan &value)
15 {
16  return out << value.toString(ChronoUtilities::TimeSpanOutputFormat::Normal, false);
17 }
18 
19 inline std::ostream &operator<<(std::ostream &out, const ChronoUtilities::Period &value)
20 {
21  return out << value.years() << " years, " << value.months() << " months, " << value.days() << " days";
22 }
23 
24 #endif // CHRONO_FORMAT_H
std::string toString(DateTimeOutputFormat format=DateTimeOutputFormat::DateAndTime, bool noMilliseconds=false) const
Returns the string representation of the current instance using the specified format.
Definition: datetime.cpp:197
Represents an instant in time, typically expressed as a date and time of day.
Definition: datetime.h:52
std::ostream & operator<<(std::ostream &out, const ChronoUtilities::DateTime &value)
Definition: format.h:9
Represents a time interval.
Definition: timespan.h:28
std::string toString(TimeSpanOutputFormat format=TimeSpanOutputFormat::Normal, bool fullSeconds=false) const
Converts the value of the current TimeSpan object to its equivalent std::string representation accord...
Definition: timespan.cpp:79
Represents a period of time.
Definition: period.h:8
int days() const
Returns the days component of the period represented by the current instance.
Definition: period.h:40
int years() const
Returns the years component of the period represented by the current instance.
Definition: period.h:24
int months() const
Returns the months component of the period represented by the current instance.
Definition: period.h:32