Date Processing in C ++

I am sure that this kind of questions should have been asked before, but it was not possible to find anything by doing a search on this site. My apologies in advance if I missed any such questions.

  • Is there anything in C ++ that just handles a date? I know the SYSTEMTIME structure (this is the structure returned when you use GetSystemTime, I think), but it does not seem to contain any manipulation functions. For example, I look at what might "give me the day of the second Tuesday in July 2010." Also, setting the time not received from the system clock to the SYSTEMTIME structure just seems, well, wrong.

  • Is there any library procedure for checking the date at all? I donโ€™t think that the main "check day is from 1 to 28." The routine should be able to say that 29-02-2009 does not exist, for example.

Thanks.

+4
source share
2 answers

You should check Boost :: DateTime .

But in order to answer your question, in C ++ there is no time for handling "how" in C ++

+8
source

The SYSTEMTIME structure and the GetSystemTime () function are functions of the Windows API and are not part of the main language or standard library. I know this is a little picky, but it can save some embarrassment later if someone who is not on Windows reads this.

I would prefer the recommendation for the Boost :: DateTime library that Chris made. As an aside, if you want to write standard C ++, you really only have the old C date and time functions, which are also in ctime . But if you really weren't stuck in a store where for some reason you can't use boost, I would go with Boost :: DateTime.

+2
source

All Articles