BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TDateTime

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE)
View previous topic :: View next topic  
Author Message
Irwin Aschkenas
Guest





PostPosted: Sun Feb 20, 2005 5:08 am    Post subject: TDateTime Reply with quote



Is there anyway to view a TDateTime in the debugger as a formatted date
string instead of a float ?

Thanks



Back to top
Harold Howe [TeamB]
Guest





PostPosted: Mon Feb 21, 2005 4:11 pm    Post subject: Re: TDateTime Reply with quote



Irwin Aschkenas wrote:

Quote:
Is there anyway to view a TDateTime in the debugger as a formatted date
string instead of a float ?

Try Evaluate/Modify on the method that converts the datetime object to a
string. This might work from the watch window, if you enable side
effects for the watch.

H^2

Back to top
Irwin Aschkenas
Guest





PostPosted: Mon Feb 21, 2005 8:13 pm    Post subject: Re: TDateTime Reply with quote



I tried it, but got an error "Cannot initialize const System::AnsiString &
with char *"

Basically I had a variable called xxxTime of TDateTime of lets says class a.

So in the inspect or the watch window I tried

a->xxxtime.FormatString( "yyyy-mm-dd hh:nn:ss.zzz" )

"Harold Howe [TeamB]" <hhowe (AT) dontcallmehoward (DOT) com> wrote

Quote:
Irwin Aschkenas wrote:

Is there anyway to view a TDateTime in the debugger as a formatted date
string instead of a float ?

Try Evaluate/Modify on the method that converts the datetime object to a
string. This might work from the watch window, if you enable side
effects for the watch.

H^2



Back to top
Harold Howe [TeamB]
Guest





PostPosted: Tue Feb 22, 2005 6:37 pm    Post subject: Re: TDateTime Reply with quote

Irwin Aschkenas wrote:

Quote:
I tried it, but got an error "Cannot initialize const System::AnsiString &
with char *"

Basically I had a variable called xxxTime of TDateTime of lets says class a.

So in the inspect or the watch window I tried

a->xxxtime.FormatString( "yyyy-mm-dd hh:nn:ss.zzz" )

The evaulate modify window probably cannot do the same method resolution
and type conversion logic that the C++ compiler does.

Two ideas:

1 - Doesn't TDateTime have a simple method for converting to a string
that doesn't take any arguments? Try that.

2- If that's not good enough, add a const AnsiString to your code:

const AnsiString DEBUG_DATE_FORMATTER = "yyyy-mm-dd hh:nn:ss.zzz"

In the evaluate window, try

a->xxxtime.FormatString( DEBUG_DATE_FORMATTER)

I don't know if this will work. I don't have BCB handy at the moment,
otherwise I would try it on my own.

H^2

Back to top
Danzer
Guest





PostPosted: Thu Feb 24, 2005 10:25 pm    Post subject: Re: TDateTime Reply with quote

Irwin Aschkenas wrote:

Quote:
Is there anyway to view a TDateTime in the debugger as a formatted date
string instead of a float ?

Thanks




// A small application to illustrate a possible solution.

#include <windows.h>
#include <dateutils.hpp>

#define DATEDEBUG

/*
If DATEDEBUG is defined,
TDebugDateTime acts as a wrapper for TDateTime.
The constructor and operators keep DateStr
in sync with the value of Date.
If DATEDEBUG is not defined,
TDATETIME is the same as TDateTime.
Your developmental application with debugging turn on,
could define DATEDEBUG allowing you to monitor DateStr.
Your production application would not define DATEDEBUG and
it would perform as TDateTime. You might need to overload
additional operators depending on your application.
*/

#ifdef DATEDEBUG
#define TDATETIME TDebugDateTime
class TDebugDateTime
{
TDateTime Date;
AnsiString DateStr;
public:
TDebugDateTime() {}
TDebugDateTime(unsigned short year,
unsigned short month,
unsigned short day)
{
Date = TDateTime(year,month,day);
DateStr = DateToStr(Date);
}
~TDebugDateTime() {}

operator TDateTime& ()
{
return Date;
}
TDateTime operator=(TDateTime date)
{
Date = date;
DateStr = DateToStr(Date);
return Date;
}
};
#else
#define TDATETIME TDateTime
#endif

int main()
{
/*
Set breakpoints at lines A, B and C.
You can see the value of DateStr change.
*/
TDateTime Today = Date();
TDATETIME Date(1999,12,31);
::Sleep(0); // Line A.
Date = IncDay(Date,1);
::Sleep(0); // Line B.
Date = Today;
::Sleep(0); // Line C.

return 0;
}

Back to top
Irwin Aschkenas
Guest





PostPosted: Fri Feb 25, 2005 5:45 am    Post subject: Re: TDateTime Reply with quote

Thanks for the possible solution. It just blows my mind how Borland can
have defined their own type TDateTime and not provide a way to view it in
the debugger. I am surprised not many people have complained and I guess
they haven't since they are up to version 6.

"Danzer" <danzer (AT) REMOVEknology (DOT) net> wrote

Quote:
Irwin Aschkenas wrote:

Is there anyway to view a TDateTime in the debugger as a formatted date
string instead of a float ?

Thanks




// A small application to illustrate a possible solution.

#include #include
#define DATEDEBUG

/*
If DATEDEBUG is defined,
TDebugDateTime acts as a wrapper for TDateTime.
The constructor and operators keep DateStr
in sync with the value of Date.
If DATEDEBUG is not defined,
TDATETIME is the same as TDateTime.
Your developmental application with debugging turn on,
could define DATEDEBUG allowing you to monitor DateStr.
Your production application would not define DATEDEBUG and
it would perform as TDateTime. You might need to overload
additional operators depending on your application.
*/

#ifdef DATEDEBUG
#define TDATETIME TDebugDateTime
class TDebugDateTime
{
TDateTime Date;
AnsiString DateStr;
public:
TDebugDateTime() {}
TDebugDateTime(unsigned short year,
unsigned short month,
unsigned short day)
{
Date = TDateTime(year,month,day);
DateStr = DateToStr(Date);
}
~TDebugDateTime() {}

operator TDateTime& ()
{
return Date;
}
TDateTime operator=(TDateTime date)
{
Date = date;
DateStr = DateToStr(Date);
return Date;
}
};
#else
#define TDATETIME TDateTime
#endif

int main()
{
/*
Set breakpoints at lines A, B and C.
You can see the value of DateStr change.
*/
TDateTime Today = Date();
TDATETIME Date(1999,12,31);
::Sleep(0); // Line A.
Date = IncDay(Date,1);
::Sleep(0); // Line B.
Date = Today;
::Sleep(0); // Line C.

return 0;
}



Back to top
Jonathan Benedicto
Guest





PostPosted: Fri Feb 25, 2005 5:53 am    Post subject: Re: TDateTime Reply with quote

Inspect this in the debugger :

dt.DateTimeString() replacing dt with your TDateTime variable.

--
Jonathan

Quote:
Is there anyway to view a TDateTime in the debugger as a formatted
date
string instead of a float ?



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.