mirror of
https://github.com/fmtlib/fmt.git
synced 2025-10-28 04:31:44 +01:00
Implement time formatting
This commit is contained in:
@@ -47,6 +47,8 @@
|
||||
#define None 0
|
||||
|
||||
#include "fmt/format.h"
|
||||
#include "fmt/time.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "mock-allocator.h"
|
||||
#include "gtest-extra.h"
|
||||
@@ -1578,6 +1580,15 @@ TEST(FormatTest, Variadic) {
|
||||
EXPECT_EQ(L"abc1", format(L"{}c{}", L"ab", 1));
|
||||
}
|
||||
|
||||
TEST(FormatTest, Time) {
|
||||
std::tm tm = std::tm();
|
||||
tm.tm_year = 116;
|
||||
tm.tm_mon = 3;
|
||||
tm.tm_mday = 25;
|
||||
EXPECT_EQ("The date is 2016-04-25.",
|
||||
fmt::format("The date is {:%Y-%m-%d}.", tm));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string str(const T &value) {
|
||||
return fmt::format("{}", value);
|
||||
|
||||
Reference in New Issue
Block a user