[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] [c++] læse en fils timestamp



Jamen du behøver slet ikke bruge de milisekunder til noget. Hvis det er filens oprettelsestid du skal bruge så er det struct timespec.st_mtim.tv_sec du skal bruge og det er en helt normal time_t. Hvis du fx har en struct timespec der hedder stbuf, så kunne det være:

ftime=localtime( &stbuf.st_mtim.tv_sec );
strftime( timbuf, 19, "%y%m%d - %H%M%S", ftime );
printf( "%s\n", timbuf );

Jeg har selv brugt det for nylig. Bare glem tv_nsec til normale formål. NB! Dette er normal c, men mon ikke det virker for c++ også.

M.v.h.
Søren


Peter Makholm wrote:


Kristian Nørgaard <sslug@sslug> writes:



Great! Og hvordan konverterer jeg dernæst den
"millisekunder-siden-1970"-tid, som jeg får ud af struct'en, til en
mere human-readable dato?



med funktionerne localtime og strftime


(Men jeg ved ikke om der er bedre C++ metoder. ovenstående er C-måden
at gøre ting på)






 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *