File: common.cpp

package info (click to toggle)
sqlitestudio 3.4.21-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 61,476 kB
  • sloc: ansic: 406,208; cpp: 123,881; yacc: 2,692; java: 992; tcl: 497; sh: 462; xml: 426; makefile: 19
file content (24 lines) | stat: -rw-r--r-- 745 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "common.h"
#include <ctime>
#include <locale>
#include <cstring>

namespace Debug {
    tm now() {
        time_t now = time(0);
        return *localtime(&now);
    }

#ifdef _WIN32
    std::wostream& formatDateTime(std::wostream& out, const tm& t, const wchar_t* fmt) {
        const std::time_put<wchar_t>& dateWriter = std::use_facet<std::time_put<wchar_t> >(out.getloc());
        const size_t n = wcslen(fmt);
#else
    std::ostream& formatDateTime(std::ostream& out, const tm& t, const char* fmt) {
        const std::time_put<char>& dateWriter = std::use_facet<std::time_put<char> >(out.getloc());
        const size_t n = strlen(fmt);
#endif
        dateWriter.put(out, out, ' ', &t, fmt, fmt + n);
        return out;
    }
}