Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting month from boost date object

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.

like image 447
Ricketyship Avatar asked Jan 06 '14 06:01

Ricketyship


1 Answers

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

like image 171
jfly Avatar answered Sep 24 '22 15:09

jfly