Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemoryWriter does not support std::put_time #283

Closed
duckie opened this issue Mar 1, 2016 · 3 comments
Closed

MemoryWriter does not support std::put_time #283

duckie opened this issue Mar 1, 2016 · 3 comments

Comments

@duckie
Copy link

duckie commented Mar 1, 2016

std::basic_ostream supports the new std::put_time function.

I am not surprised since this is not the classic << overload as according to the documentation: http://en.cppreference.com/w/cpp/io/manip/put_time.

Not sure if cppformat should support it, but it would be nice.

@vitaut
Copy link
Contributor

vitaut commented Mar 2, 2016

Good idea. It should be possible to do something like:

    std::time_t t = std::time(nullptr);
    std::tm tm = *std::localtime(&t);
    fmt::print("{:%c %Z}", tm);

with a custom formatting function.

@vitaut
Copy link
Contributor

vitaut commented Apr 25, 2016

Time formatting has been implemented in fa5ebd2. Here's an example:

#include "fmt/time.h"

std::time_t t = std::time(nullptr);
fmt::print("The date is {:%Y-%m-%d}.", *std::localtime(&t));

This just needs to be documented.

@vitaut
Copy link
Contributor

vitaut commented Apr 29, 2016

@vitaut vitaut closed this as completed Apr 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants