-1

I have been using C++ Builder to develop some classes. I have been using the TDateTime data type by including the 'vcl.h'. Is this only unique to C++ Builder?

I ask this because I am now using Microsoft Visual Studio C++ and am getting a 'TDateTime is undefined error'.

How can I use this type in Visual Studio?

Thanks

user1690531
  • 231
  • 1
  • 6
  • 17
  • 1
    `TDateTime` is certainly not part of the standard C++ library. – juanchopanza Sep 22 '12 at 08:07
  • How can I add this to my Project? – user1690531 Sep 22 '12 at 08:14
  • I don't know if you can intal it by itself, but would you be interested in open source and/or C++ standard alternatives? – juanchopanza Sep 22 '12 at 08:15
  • Yes I would be. Shall I try Bloodshed? Basically, I am wanting to use my C++ Builder code (that uses the TDateTime data type) in another C++ development IDE. My evaluation version runs out tomorrow... – user1690531 Sep 22 '12 at 08:23
  • I have added some suggestions in an answer. Unfortunately, I don't think they provide an easy drop-in replacement, but with a bit of work you can get the functionality you need. – juanchopanza Sep 22 '12 at 08:31

2 Answers2

2

I would suggest having a look at boost.datetime and, if you have access to C++11 support, the standard C++ time and time duration utilities available in the <chrono> header. One advantage of using either of these is that they are portable, so you are not bound to a given compiler or development environment.

juanchopanza
  • 223,364
  • 34
  • 402
  • 480
  • The thing is. I have already written hundreds of lines of code, and they use the TDateTime object. I do not want to rewrite everything with a different data type... – user1690531 Sep 22 '12 at 08:32
  • @user1690531 That's the kind of thing you need to expect when migrating vendor-specific code from one compiler/platform to another. (hence the reason "portable" libraries exist and are generally quite popular). Rewriting is usually the best option; the only other (**worse**) alternative is to create your own type called `TDateTime` in visual C++ which takes the TDateTime interface but acts as a wrapper for another date/time library of your choice – Ben Cottrell Sep 22 '12 at 08:39
  • Can I just include the library that C++ Builder uses? – user1690531 Sep 22 '12 at 08:39
  • @user1690531 The best way to answer that question is to try it for yourself. As I mentioned in my answer - much of the VCL is built around Borland-specific extensions and uses delphi code; Visual C++ doesn't know anything about those, so doing that may need you to jump through a lot of hoops. – Ben Cottrell Sep 22 '12 at 08:45
  • @user1690531 It is very likely to be a proprietary library, but I can't say for sure. I really suggest rolling out your own date-time code using a portable solution. – juanchopanza Sep 22 '12 at 08:47
1

Most of Borland's Visual Component Library is built around it's own compiler-specific extensions and delphi code. I very much doubt you will have an easy time getting it to work under any other compiler.

LUckily there are plenty of alternatives. If you're using Visual C++, then you can use Microsoft's Date/Time libraries: http://msdn.microsoft.com/en-us/library/6ahxxcsz%28v=vs.100%29.aspx

There are also portable libraries from Boost and QT which should run under any modern C++ compiler

Ben Cottrell
  • 5,741
  • 1
  • 27
  • 34
  • 1
    1) Borland is now Embarcadero 2) I would strongly focus on starting date of a [`TDateTime`](http://docwiki.embarcadero.com/Libraries/en/System.TDateTime) data type and if it matches to those you've suggested. – TLama Sep 22 '12 at 10:52