views:

30

answers:

3

In our company we use ints to store Date values. The logic behind it is quite simple. The int contains the number of days since 1.1.1970. We have our own functions to convert these ints to strings at runtime.

My problem is, that I haven't found a way to tell the debugger to display these values as Dates (strings). I only see 40345 and I have to use an external tool to convert that to a Date. That makes me sick and slows down debugging.

I have already tried to call the convert function in the watchlist, but it only shows a lot of errors.

Please help me, I'm so tired of guessing Date Values.

A: 

You can add a cast to the right type in the watch window.

Code Clown
This can't work. VS does not know anything about our internal representation of a date value.
+2  A: 

Edit: sorry, missed the c++ tag somehow, this just works in C#...

Type new DateTime(1970,1,1).AddDays(foo) in the watchlist where foo is your variable.

Albin Sunnanbo
This doesn't work for me. Even when I change foo to a fixed value I get an error saying CXX0013: Error: Operator missing (I translated the error message). I'm using Visual Studio 2008.
A: 

Solution

I solved it myself. The debugger seems to handle only standard c built-in types. I created a simple function that returned a pointer to a char array allocated on the heap containing a copy of the string. This works fine an is very easy to use.