#include <iostream>
#include <string>
#include <iterator>
#include <locale>
#include <time.h>

using namespace std;

class timefmt
{
public:
    timefmt(std::string fmt)
        : format(fmt) { }

    friend ostream& operator <<(ostream &, timefmt const &);

private:
    string format;
};


std::ostream& operator <<(std::ostream& os, timefmt const& mt)
{
    std::ostream::sentry s(os);

    if (s)
    {
        time_t t = time(0);
        tm const* tm = localtime(&t);
        ostreambuf_iterator<char> out(os);

        use_facet<time_put<char>>(os.getloc())
            .put(out, os, os.fill(),
                 tm, &mt.format[0], &mt.format[0] + mt.format.size());
    }

    os.width(0);

    return os;
}

int main() {}