OWLNext
7.0
Borland's Object Windows Library for the modern age
Toggle main menu visibility
Loading...
Searching...
No Matches
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
14
#include <
owl/private/strmdefs.h
>
15
#include <iomanip>
16
17
using namespace
std;
18
19
namespace
owl
{
20
21
//
22
// Static variable intialization:
23
//
24
int
TTime::PrintDateFlag = 1;
25
26
//
27
/// Returns a string object containing the time.
28
//
29
tstring
TTime::AsString
()
const
30
{
31
tostringstream
strtemp;
32
strtemp << (*this);
33
return
strtemp.str();
34
}
35
36
/* -------------------------------------------------------------------------- */
37
38
//
39
/// Inserts time t into output stream os.
40
//
41
_OWLCFUNC
(
tostream
&)
operator <<
(
tostream
& s,
const
TTime
& t)
42
{
43
// We use an ostrstream to format into buf so that
44
// we don't affect the ostream's width setting.
45
//
46
tostringstream
out;
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.
69
int
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.
77
_OWLCFUNC
(
tostream
&)
operator <<
(
tostream
& os,
const
TFileStatus
& status )
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
/* ========================================================================== */
owl::TDate::TDate
TDate()
Construct a TDate with the current date.
Definition
date.cpp:68
owl::TTime::Second
SecondTy Second() const
Returns seconds.
Definition
time.cpp:332
owl::TTime::Minute
MinuteTy Minute() const
Returns the minute in local time.
Definition
time.cpp:316
owl::TTime::Hour
HourTy Hour() const
Returns the hour in local time.
Definition
time.cpp:266
owl::TTime::PrintDate
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
owl::TTime::TTime
TTime()
Construct TTime with current time (seconds since Jan 1, 1901).
Definition
time.cpp:137
owl::TTime::AsString
tstring AsString() const
Returns a string object containing the time.
Definition
timeio.cpp:29
_T
#define _T(x)
Definition
cygwin.h:51
file.h
pch.h
owl
Object Windows Library (OWLNext Core).
Definition
animctrl.h:22
owl::tostringstream
std::ostringstream tostringstream
Definition
strmdefs.h:36
owl::operator<<
owl::opstream & operator<<(owl::opstream &os, const TColor &c)
Insert the color value into a persistent output stream.
Definition
color.h:498
owl::tstring
std::string tstring
Definition
defs.h:79
owl::tostream
std::ostream tostream
Definition
strmdefs.h:40
_OWLCFUNC
#define _OWLCFUNC(p)
Definition
defs.h:342
strmdefs.h
owl::TFileStatus
Definition
file.h:35
owl::TFileStatus::size
uint32 size
Definition
file.h:39
owl::TFileStatus::fullName
tchar fullName[_MAX_PATH]
Definition
file.h:41
owl::TFileStatus::attribute
uint attribute
Definition
file.h:40
owl::TFileStatus::modifyTime
TTime modifyTime
Definition
file.h:37
owl::TFileStatus::createTime
TTime createTime
Definition
file.h:36
owl::TFileStatus::accessTime
TTime accessTime
Definition
file.h:38
time.h
source
owlcore
timeio.cpp
Generated by
1.18.0