Question

I have a boost::date object. When I call month() interface on the object it returns me the month the object is holding but in terms of a string. Is there a way I can get the number associated with the month? i.e

date mySampleDate = date_from_tm(tm_myDate) ;
cout<<mySampleDate.month() ; //Gives the output as May/Jun/Jul etc. I need 5/6/7 etc.

I need to get this without recoverting the boost object into tm structure. This would result in too many converstions and a possible performance hit for me.

Was it helpful?

Solution

cout<<mySampleDate.month().as_number(); is exactly what you want!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top