1 //===- Support/Chrono.cpp - Utilities for Timing Manipulation ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Support/Chrono.h"
11 #include "llvm/Config/config.h"
12 #include "llvm/Support/Format.h"
13 #include "llvm/Support/raw_ostream.h"
19 static inline struct tm getStructTM(TimePoint<> TP) {
21 std::time_t OurTime = toTimeT(TP);
23 #if defined(LLVM_ON_UNIX)
24 struct tm *LT = ::localtime_r(&OurTime, &Storage);
28 #if defined(LLVM_ON_WIN32)
29 int Error = ::localtime_s(&Storage, &OurTime);
37 raw_ostream &operator<<(raw_ostream &OS, TimePoint<> TP) {
38 struct tm LT = getStructTM(TP);
39 char Buffer[sizeof("YYYY-MM-DD HH:MM:SS")];
40 strftime(Buffer, sizeof(Buffer), "%Y-%m-%d %H:%M:%S", <);
41 return OS << Buffer << '.'
43 long((TP.time_since_epoch() % std::chrono::seconds(1))