Skip to content

Commit 631a998

Browse files
util: Added now() to isotime
1 parent 4ae2099 commit 631a998

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

api/util/isotime.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ namespace isotime
3838
strftime(buf, sizeof buf, "%FT%TZ", gmtime(&ts));
3939
return buf;
4040
}
41+
42+
/**
43+
* @brief Returns the current time as a datetime according "to_datetime_string"
44+
*
45+
* @return A datetime string representing now
46+
*/
47+
std::string now()
48+
{
49+
return to_datetime_string(time(0));
50+
}
4151
}
4252

4353
#endif

examples/acorn/service.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ Disk_ptr disk;
4141

4242
#include <isotime>
4343
// Get current date/time, format is [YYYY-MM-DDTHH:mm:ssZ]
44-
const std::string timestamp() {
45-
time_t now = time(0);
46-
return "[" + isotime::to_datetime_string(now) + "] ";
47-
}
44+
const std::string timestamp()
45+
{ return "[" + isotime::now() + "] "; }
4846

4947
#include <net/inet4>
5048

0 commit comments

Comments
 (0)