Marked Easy::time operators const.

This commit is contained in:
tastytea 2019-04-13 02:27:45 +02:00
parent a3f2e94034
commit bc82dac69b
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 21 additions and 9 deletions

View File

@ -18,12 +18,12 @@
using namespace Mastodon; using namespace Mastodon;
Easy::time::operator const system_clock::time_point() Easy::time::operator const system_clock::time_point() const
{ {
return timepoint; return timepoint;
} }
Easy::time::operator const string() Easy::time::operator const string() const
{ {
return strtime("%FT%T%z", true); 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, std::ostream &Mastodon::Easy::operator <<(std::ostream &out,
const Easy::time &t) const Easy::time &t)
{ {
out << t.strtime("%FT%T%z", true); const string s = t; // Converts using operator const string().
out << s;
return out; return out;
} }

View File

@ -48,6 +48,7 @@ namespace Easy
* *
* @since before 0.11.0 * @since before 0.11.0
*/ */
// TODO: What about instance-only?
enum class visibility_type enum class visibility_type
{ {
Direct, Direct,
@ -62,6 +63,7 @@ namespace Easy
* *
* @since before 0.11.0 * @since before 0.11.0
*/ */
// TODO: Look up what Pleroma returns.
enum class attachment_type enum class attachment_type
{ {
Image, Image,
@ -102,7 +104,7 @@ namespace Easy
/*! /*!
* @brief Used for stream events. * @brief Used for stream events.
* *
* @since before 0.11.0 * @since 0.100.0
*/ */
typedef struct stream_event typedef struct stream_event
{ {
@ -117,6 +119,7 @@ namespace Easy
* *
* @since 0.13.3 * @since 0.13.3
*/ */
// TODO: Replace with struct?
typedef std::map<Easy::notification_type, bool> alertmap; typedef std::map<Easy::notification_type, bool> alertmap;
/*! /*!
@ -128,8 +131,16 @@ namespace Easy
{ {
system_clock::time_point timepoint = system_clock::time_point(); system_clock::time_point timepoint = system_clock::time_point();
operator const system_clock::time_point(); operator const system_clock::time_point() const;
operator const string();
/*
* @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, friend std::ostream &operator <<(std::ostream &out,
const Easy::time &t); const Easy::time &t);
@ -140,7 +151,7 @@ namespace Easy
* *
* @param format The format of the string, same as with * @param format The format of the string, same as with
* `strftime`. * `strftime`.
* @param local Use local time (default). * @param local Use local time (default) or UTC.
* *
* Example: * Example:
* @code * @code
@ -152,8 +163,8 @@ namespace Easy
* *
* @since 0.100.0 * @since 0.100.0
*/ */
const string strtime (const string &format, const string strtime(const string &format,
const bool &local = true) const; const bool &local = true) const;
}; };
} }
} }