C++ Utilities 5.24.8
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Loading...
Searching...
No Matches
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
9inline std::ostream &operator<<(std::ostream &out, const CppUtilities::DateTime &value)
10{
12}
13
14inline std::ostream &operator<<(std::ostream &out, const CppUtilities::DateTimeExpression &value)
15{
16 return out << value.toIsoString();
17}
18
19inline std::ostream &operator<<(std::ostream &out, const CppUtilities::TimeSpan &value)
20{
21 return out << value.toString(CppUtilities::TimeSpanOutputFormat::Normal, false);
22}
23
24inline std::ostream &operator<<(std::ostream &out, const CppUtilities::Period &value)
25{
26 return out << value.years() << " years, " << value.months() << " months, " << value.days() << " days";
27}
28
29#endif // CHRONO_FORMAT_H
Represents an instant in time, typically expressed as a date and time of day.
Definition datetime.h:55
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.h:468
Represents a period of time.
Definition period.h:8
constexpr int days() const
Returns the days component of the period represented by the current instance.
Definition period.h:48
constexpr int years() const
Returns the years component of the period represented by the current instance.
Definition period.h:32
constexpr int months() const
Returns the months component of the period represented by the current instance.
Definition period.h:40
Represents a time interval.
Definition timespan.h:25
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.h:528
std::ostream & operator<<(std::ostream &out, const CppUtilities::DateTime &value)
Definition format.h:9
The DateTimeExpression struct holds information about a time expression (e.g.
Definition datetime.h:163
std::string toIsoString(char dateDelimiter='-', char timeDelimiter=':', char timeZoneDelimiter=':') const
Returns the string representation of the current instance in the ISO format.
Definition datetime.cpp:533