vendredi 18 septembre 2020

How to get Current date using Poco ? (Only Date) No Time Stamp

Is there a way we get a Date only from Poco ? One way is to get the Poco DateTime stamp and truncate the Date, But is there any way which gives directly current Date ? Like for example I am using like this to get Date

void getTimestamp(std::string &out_iTimestamp)
{
   //Get the CurrentTimestamp
   Poco::Timestamp t_oCurTimestamp;
   Poco::DateTimeFormatter t_oFormatter;
   string t_strDateTime;
   t_oFormatter.append(t_strDateTime, t_oCurTimestamp, Poco::DateTimeFormat::ISO8601_FORMAT);
   out_iTimestamp = t_strDateTime;

} Now I am truncating the Date

std::string t_strDateTime;
std::string t_strDate;
getTimestamp(t_strDateTime);
//extract the only Date from DateTimeStamp
std::size_t found = t_strDateTime.find('T');
if (found != std::string::npos){
    t_strDate = t_strDateTime.substr(0,found);
}

Any one know the simple way ?

Aucun commentaire:

Enregistrer un commentaire