OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
timeio.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1993, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// TTime class IO and conversion implementation
7//----------------------------------------------------------------------------
8#include <owl/pch.h>
9
10#include <owl/time.h>
11
12#include <owl/file.h>
13
15#include <iomanip>
16
17using namespace std;
18
19namespace owl {
20
21//
22// Static variable intialization:
23//
24int TTime::PrintDateFlag = 1;
25
26//
27/// Returns a string object containing the time.
28//
30{
32 strtemp << (*this);
33 return strtemp.str();
34}
35
36/* -------------------------------------------------------------------------- */
37
38//
39/// Inserts time t into output stream os.
40//
42{
43 // We use an ostrstream to format into buf so that
44 // we don't affect the ostream's width setting.
45 //
47
48 // First print the date if requested:
49 //
50 if(TTime::PrintDateFlag)
51 out << TDate(t) << _T(" ");
52
53 unsigned hh = t.Hour();
54 out << (hh <= 12 ? hh : hh-12) << _T(':');
55 out << setfill(_T('0'));
56 out << setw(2);
57 out << t.Minute() << _T(':');
58 out << setw(2);
59 out << t.Second() << _T(' ');
60 out << setfill(_T(' '));
61 out << ( hh<12 ? _T("am") : _T("pm"));
62
63 s << out.str();
64 return s;
65}
66
67/// Set flag to 1 to print the date along with the time; set to 0 to not print the
68/// date. Returns the old setting.
69int TTime::PrintDate( int f )
70{
71 int temp = PrintDateFlag;
72 PrintDateFlag = f;
73 return temp;
74}
75
76/// Inserts time t into persistent stream s.
78{
79 os << _T("File Status: ") << status.fullName << endl;
80 os << _T(" created: ") << status.createTime << endl;
81 os << _T(" modified: ") << status.modifyTime << endl;
82 os << _T(" accessed: ") << status.accessTime << endl;
83 os << _T(" size: ") << status.size << endl;
84 os << _T(" attributes: ") << static_cast<int>(status.attribute) << endl;
85 return os;
86}
87
88} // OWL namespace
89/* ========================================================================== */
The TDate class represents a date.
Definition date.h:48
The TTime class encapsulates time functions and characteristics.
Definition time.h:38
SecondTy Second() const
Returns seconds.
Definition time.cpp:332
MinuteTy Minute() const
Returns the minute in local time.
Definition time.cpp:316
HourTy Hour() const
Returns the hour in local time.
Definition time.cpp:266
static int PrintDate(int)
Set flag to 1 to print the date along with the time; set to 0 to not print the date.
Definition timeio.cpp:69
tstring AsString() const
Returns a string object containing the time.
Definition timeio.cpp:29
#define _T(x)
Definition cygwin.h:51
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
std::ostringstream tostringstream
Definition strmdefs.h:36
owl::opstream & operator<<(owl::opstream &os, const TColor &c)
Insert the color value into a persistent output stream.
Definition color.h:498
std::string tstring
Definition defs.h:79
std::ostream tostream
Definition strmdefs.h:40
#define _OWLCFUNC(p)
Definition defs.h:342
uint32 size
Definition file.h:39
tchar fullName[_MAX_PATH]
Definition file.h:41
uint attribute
Definition file.h:40
TTime modifyTime
Definition file.h:37
TTime createTime
Definition file.h:36
TTime accessTime
Definition file.h:38