Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Date & Time representation in "struct stat" - <sys/stat.h> (http://www.velocityreviews.com/forums/t542179-date-and-time-representation-in-struct-stat-sys-stat-h.html)

Magesh 10-05-2007 09:02 AM

Date & Time representation in "struct stat" - <sys/stat.h>
 
How date-time attributes of a file are represented in the structure
"struct stat"? Coz as I noted they found to be unsigned integers and I
donno how they are interpreted as date & time in the members st_atime,
st_mtime, and st_ctime. I don't want any lib fun that returns the
corresponding time formatted string coz what I want to know is the
interpretation of date-time in those members so that I could extract
them and use it for some purpose.

Thx in advance to whoever participates this discussion...
- Magesh


Joachim Schmitz 10-05-2007 09:13 AM

Re: Date & Time representation in "struct stat" - <sys/stat.h>
 
"Magesh" <gs.magesh@gmail.com> schrieb im Newsbeitrag
news:1191574971.163401.5460@k79g2000hse.googlegrou ps.com...
> How date-time attributes of a file are represented in the structure
> "struct stat"? Coz as I noted they found to be unsigned integers and I
> donno how they are interpreted as date & time in the members st_atime,
> st_mtime, and st_ctime. I don't want any lib fun that returns the
> corresponding time formatted string coz what I want to know is the
> interpretation of date-time in those members so that I could extract
> them and use it for some purpose.

These are seconds since the Epoch (1st Jan 1970 0:00 GMT)

However: this isn't the right NG as stat() and this struct statare not part
of any C Standard but part of POSIX, so comp.unix.programmer would be the
right place. (Follow up set, I hope)

Bye, Jojo



Mark Bluemel 10-05-2007 09:16 AM

Re: Date & Time representation in "struct stat" - <sys/stat.h>
 
Magesh wrote:
> How date-time attributes of a file are represented in the structure
> "struct stat"? Coz as I noted they found to be unsigned integers and I
> donno how they are interpreted as date & time in the members st_atime,
> st_mtime, and st_ctime. I don't want any lib fun that returns the
> corresponding time formatted string coz what I want to know is the
> interpretation of date-time in those members so that I could extract
> them and use it for some purpose.
>
> Thx in advance to whoever participates this discussion...


stat.h is required by POSIX, not by the C language specification.

Your question is really a Unix(-like) question rather than a C question
and would be better directed to comp.unix.programmer (I'd set followups
if my newsreader let me).

<Off-topic>

See http://en.wikipedia.org/wiki/Unix_time for a discussion of Unix time
handling.

</Off-topic>

Gordon Burditt 10-05-2007 12:13 PM

Re: Date & Time representation in "struct stat" - <sys/stat.h>
 
>How date-time attributes of a file are represented in the structure
>"struct stat"? Coz as I noted they found to be unsigned integers and I
>donno how they are interpreted as date & time in the members st_atime,
>st_mtime, and st_ctime. I don't want any lib fun that returns the
>corresponding time formatted string coz what I want to know is the
>interpretation of date-time in those members so that I could extract
>them and use it for some purpose.


C does not define a struct stat, however, typically the elements
you refer to are a time_t. (Or maybe a structure containing a
time_t and something representing fractional seconds.) See also
localtime() and ctime(). ctime() does format them as a string but
localtime() breaks it down into a struct tm, which you can use for
various things like figuring out the day of the week the file was
last modified.



All times are GMT. The time now is 04:36 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.