Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Date & Time representation in "struct stat" - <sys/stat.h>

Reply
Thread Tools

Date & Time representation in "struct stat" - <sys/stat.h>

 
 
Magesh
Guest
Posts: n/a
 
      10-05-2007
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

 
Reply With Quote
 
 
 
 
Joachim Schmitz
Guest
Posts: n/a
 
      10-05-2007
"Magesh" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed) 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


 
Reply With Quote
 
 
 
 
Mark Bluemel
Guest
Posts: n/a
 
      10-05-2007
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>
 
Reply With Quote
 
Gordon Burditt
Guest
Posts: n/a
 
      10-05-2007
>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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
w3.org suggestion .. page, date, time and topic, date, time code (wish list). Keith Cochrane HTML 2 08-06-2006 06:57 AM
covert time from date Hour min sec format to epoch time i.e time since 1 jan 1970 in C Summu82 C Programming 5 06-07-2006 02:51 PM
datagrid sort string (is representation of date) as a DATE cindy ASP .Net Datagrid Control 1 03-31-2006 09:29 AM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Date & Time chooser for java 1.1 - using only the mouse to select time & date Chris Berg Java 0 10-27-2003 10:59 PM



Advertisments