Reid Spencer | 0d5716e | 2004-09-25 05:03:54 +0000 | [diff] [blame] | 1 | //===- Unix/TimeValue.cpp - Unix TimeValue Implementation -------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Reid Spencer and is distributed under the |
| 6 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the Unix specific portion of the TimeValue class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | //=== WARNING: Implementation here must contain only generic UNIX code that |
| 16 | //=== is guaranteed to work on *all* UNIX variants. |
| 17 | //===----------------------------------------------------------------------===// |
| 18 | |
| 19 | #include "Unix.h" |
| 20 | |
Reid Spencer | d351871 | 2004-11-14 22:10:08 +0000 | [diff] [blame] | 21 | #include <time.h> |
| 22 | |
| 23 | namespace llvm { |
| 24 | using namespace sys; |
| 25 | |
| 26 | |
| 27 | std::string TimeValue::toString() { |
| 28 | char buffer[32]; |
| 29 | |
| 30 | time_t ourTime = time_t(this->toEpochTime()); |
| 31 | ::asctime_r(::localtime(&ourTime), buffer); |
| 32 | |
| 33 | std::string result(buffer); |
| 34 | return result.substr(0,24); |
| 35 | } |
| 36 | |
Reid Spencer | 0d5716e | 2004-09-25 05:03:54 +0000 | [diff] [blame] | 37 | } |
| 38 | // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab |