Original Post
RP: Subtracting Dates and Time. If today's date is 4/1/2006 I want to know 3 days ago, and that would be the 3/29/2006. is there a convential way to calculate dates using the tm structures? OP: Unexpected Results when requesting date on stat The actual thing: the C++ source The results from the C++ source code okay... why is it giving identical #'s... instead of dates and time.. could it be because... http://www.scit.wlv.ac.uk/~jphb/spos/notes/calls/stat.html
151# ls -l
total 28
drwxrwxrwx 2 nobody wheel 512 Apr 16 13:47 2BeoPccosL
drwxrwxrwx 2 nobody wheel 512 Apr 16 13:49 58nD8CDDg8
drwxrwxrwx 2 nobody wheel 512 Apr 16 13:46 7ilIlbBKi1
drwxrwxrwx 2 nobody wheel 512 Apr 16 14:00 82uxb1RC3R
drwxrwxrwx 2 nobody wheel 512 Apr 16 13:57 9S9wwwTvFp
drwxrwxrwx 2 nobody wheel 512 Apr 16 12:35 CCGxMTwzlG
drwxrwxrwx 2 nobody wheel 512 Apr 16 13:59 CX3oCk70jX
drwxrwxrwx 2 nobody wheel 512 Apr 16 13:40 GPVMejRpSz
drwxrwxrwx 2 nobody wheel 512 Apr 16 13:48 JRf7PSvghi
drwxrwxrwx 2 nobody wheel 512 Apr 16 12:45 MgQQhpUrIO
drwxrwxrwx 2 nobody wheel 512 Apr 16 13:45 OEIWptaYuG
drwxrwxrwx 2 nobody wheel 512 Apr 16 13:49 XU17bHXnMR
drwxrwxrwx 2 nobody wheel 512 Apr 16 14:08 aba6snUhe9
drwxrwxrwx 2 nobody wheel 512 Apr 16 13:50 szfN9PR7V3
for ( int i=0; i < directories.size(); i++ ){
//std::cout << directories.at(i);
struct stat sbuf;
stat( directories.at(i).c_str(), &sbuf);
innerMap["name"]=directories.at(i);
innerMap["st_mtime"]=sbuf.st_mtime;
std::cout << sbuf.st_mtime << std::endl;
std::cout << sbuf.st_atime << std::endl;
std::cout << sbuf.st_ctime << std::endl;
directoriesMap.insert(std::pair<std::string, std::map<std::string, std::string> >(innerMap["name"], innerMap ) );
}
135065600
673164044
1
135065600
673164044
1
135065600
673164044
1
135065600
673164044
1
135065600
673164044
1
135065600
673164044
1
135065600
673164044
1
135065600
673164044
1
135065600
673164044
1
135065600
673164044
1
135065600
673164044
1
135065600
673164044
1
135065600
673164044
1
135065600
673164044
from www.scit.wiv.ac.uk
time_t st_atime Time of last access
time_t st_mtime Time of last data modification
time_t st_ctime Time of last file status change
the data type returned is a time_t? maybe I need to convert this time_t into string or int format ?? I mean, still when I cout << buf.st_atime I get identical results for different things edit: please if I am missing something can you point it out... Thanks... I'm really stuck and can't find much information on the net about stat() [Edited by - Tradone on April 16, 2006 3:02:47 PM]