add ISO-8601 formatters to timefunc
[libi2ncommon] / src / timefunc.hxx
index 09e4e5c..74c16e4 100644 (file)
@@ -20,7 +20,7 @@ on this file might be covered by the GNU General Public License.
 /** @file
  * @brief time related functions.
  *
- * @copyright Copyright © 2001-2008 by Intra2net AG
+ * @copyright Copyright © 2001-2018 by Intra2net AG
  */
 
 #ifndef __TIMEFUNC_HXX
@@ -54,6 +54,16 @@ time_t date_to_seconds(const std::string &date);
 std::string make_nice_time(int seconds);
 std::string format_full_time(time_t seconds);
 std::string format_date(time_t seconds);
+std::string format_iso8601(const struct tm &tm, const bool date=true,
+                           const bool time=true, const bool tz=true);
+std::string format_iso8601(time_t t, const bool utc=true,
+                           const bool date=true, const bool time=true,
+                           const bool tz=true);
+inline std::string format_iso8601(const struct timespec ts, const bool utc=true,
+                                  const bool date=true, const bool time=true,
+                                  const bool tz=true)
+{ return format_iso8601 (ts.tv_sec, utc, date, time, tz); }
+
 void seconds_to_hour_minute(int seconds, int *hour, int *minute);
 void split_daysec(int daysec, int *outhours=NULL, int *outminutes=NULL, int *outseconds=NULL);
 std::string output_hour_minute(int hour, int minute, bool h_for_00=true, int seconds=0);