C++ Utilities: chrono/format.h Source File

C++ Utilities 5.35.0 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
9 inline std::ostream &operator<<(std::ostream &out, const CppUtilities::DateTime &value)
10{
11 return out << value.toString(CppUtilities::DateTimeOutputFormat::DateAndTime, false);
12}
13
14 inline std::ostream &operator<<(std::ostream &out, const CppUtilities::DateTimeExpression &value)
15{
16 return out << value.toIsoString();
17}
18
19 inline std::ostream &operator<<(std::ostream &out, const CppUtilities::TimeSpan &value)
20{
21 return out << value.toString(CppUtilities::TimeSpanOutputFormat::Normal, false);
22}
23
24 inline 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
CppUtilities::DateTime
Represents an instant in time, typically expressed as a date and time of day.
Definition datetime.h:55
CppUtilities::DateTime::toString
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:466
CppUtilities::Period
Represents a period of time.
Definition period.h:8
CppUtilities::Period::days
constexpr int days() const
Returns the days component of the period represented by the current instance.
Definition period.h:48
CppUtilities::Period::years
constexpr int years() const
Returns the years component of the period represented by the current instance.
Definition period.h:32
CppUtilities::Period::months
constexpr int months() const
Returns the months component of the period represented by the current instance.
Definition period.h:40
CppUtilities::TimeSpan
Represents a time interval.
Definition timespan.h:25
CppUtilities::TimeSpan::toString
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
datetime.h
operator<<
std::ostream & operator<<(std::ostream &out, const CppUtilities::DateTime &value)
Definition format.h:9
CppUtilities::TimeSpanOutputFormat::Normal
@ Normal
Definition timespan.h:20
CppUtilities::DateTimeOutputFormat::DateAndTime
@ DateAndTime
Definition datetime.h:20
period.h
CppUtilities::DateTimeExpression
The DateTimeExpression struct holds information about a time expression (e.g.
Definition datetime.h:161
CppUtilities::DateTimeExpression::toIsoString
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:544