From bc82dac69b5cc3911daa17f9b2e7164079869d94 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 13 Apr 2019 02:27:45 +0200 Subject: [PATCH] Marked Easy::time operators const. --- src/easy/types_easy.cpp | 7 ++++--- src/easy/types_easy.hpp | 23 +++++++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/easy/types_easy.cpp b/src/easy/types_easy.cpp index acad7d9..2da051c 100644 --- a/src/easy/types_easy.cpp +++ b/src/easy/types_easy.cpp @@ -18,12 +18,12 @@ using namespace Mastodon; -Easy::time::operator const system_clock::time_point() +Easy::time::operator const system_clock::time_point() const { return timepoint; } -Easy::time::operator const string() +Easy::time::operator const string() const { return strtime("%FT%T%z", true); } @@ -51,6 +51,7 @@ const string Easy::time::strtime(const string &format, const bool &local) const std::ostream &Mastodon::Easy::operator <<(std::ostream &out, const Easy::time &t) { - out << t.strtime("%FT%T%z", true); + const string s = t; // Converts using operator const string(). + out << s; return out; } diff --git a/src/easy/types_easy.hpp b/src/easy/types_easy.hpp index 646ada2..54b59b7 100644 --- a/src/easy/types_easy.hpp +++ b/src/easy/types_easy.hpp @@ -48,6 +48,7 @@ namespace Easy * * @since before 0.11.0 */ + // TODO: What about instance-only? enum class visibility_type { Direct, @@ -62,6 +63,7 @@ namespace Easy * * @since before 0.11.0 */ + // TODO: Look up what Pleroma returns. enum class attachment_type { Image, @@ -102,7 +104,7 @@ namespace Easy /*! * @brief Used for stream events. * - * @since before 0.11.0 + * @since 0.100.0 */ typedef struct stream_event { @@ -117,6 +119,7 @@ namespace Easy * * @since 0.13.3 */ + // TODO: Replace with struct? typedef std::map alertmap; /*! @@ -128,8 +131,16 @@ namespace Easy { system_clock::time_point timepoint = system_clock::time_point(); - operator const system_clock::time_point(); - operator const string(); + operator const system_clock::time_point() const; + + /* + * @brief Returns local time as string in ISO 8601 format (%FT%T%z). + */ + operator const string() const; + + /* + * @brief Returns local time as string in ISO 8601 format (%FT%T%z). + */ friend std::ostream &operator <<(std::ostream &out, const Easy::time &t); @@ -140,7 +151,7 @@ namespace Easy * * @param format The format of the string, same as with * `strftime`. - * @param local Use local time (default). + * @param local Use local time (default) or UTC. * * Example: * @code @@ -152,8 +163,8 @@ namespace Easy * * @since 0.100.0 */ - const string strtime (const string &format, - const bool &local = true) const; + const string strtime(const string &format, + const bool &local = true) const; }; } }