You're looking for a mongo::Date_t object, which will get serialized with BSON's datetime type. Its constructor takes an integer representing milliseconds since the epoch. See [1] for its definition. Once you've initialized one, you can pass it in directly to the BSON() macro in place of where "new Date(...)" was in your snippet.
You also have other options for ways to generate BSON datetime values. Here's your example using C-style dates (see [2] for definitions of the various BSONObjBuilder helper methods):
struct tm birthdate;
strptime("6 Dec 2001 12:33:45", "%d %b %Y %H:%M:%S", &birthdate);
mongo::BSONObjBuilder builder;
builder.genOID();
builder.append("name", "George");
builder.appendTimeT("birthdate", mktime(&birthdate));
mongo::BSONObj doc = builder.obj();
On Wednesday, October 31, 2012 1:18:12 PM UTC-7, George Thompson wrote:
I want to do this in C++
mongo::BSONObj doc = BSON(mongo::GENOID << "name" << "George" << "birthdate" << new Date(1990, 4, 15) );
which gives me
1>garden.cpp(59): error C2061: syntax error : identifier 'Date'
1>garden.cpp(59): error C2228: left of '.obj' must have class/struct/union
1>garden.cpp(59): error C2143: syntax error : missing ';' before ')'
1>garden.cpp(59): error C2143: syntax error : missing ';' before ')'
Which tells me I have no idea how to assign a date with the C++ driver. For the life of me, I couldn't find anything in the online docs or a google search except for a ticket requesting examples in the documentation.
So, what is the trick?