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

Discussion in 'C Programming' started by Magesh, Oct 5, 2007.

  1. Magesh

    Magesh Guest

    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
     
    Magesh, Oct 5, 2007
    #1
    1. Advertising

  2. "Magesh" <> schrieb im Newsbeitrag
    news:...
    > 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
     
    Joachim Schmitz, Oct 5, 2007
    #2
    1. Advertising

  3. Magesh

    Mark Bluemel Guest

    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>
     
    Mark Bluemel, Oct 5, 2007
    #3
  4. >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.
     
    Gordon Burditt, Oct 5, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven T. Hatton
    Replies:
    3
    Views:
    9,730
    Pete Becker
    Jun 2, 2005
  2. Patrick Useldinger

    os.stat('<filename>')[stat.ST_INO] on Windows

    Patrick Useldinger, Feb 27, 2005, in forum: Python
    Replies:
    6
    Views:
    1,195
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Mar 3, 2005
  3. Rolf Krüger
    Replies:
    2
    Views:
    630
    Ian Collins
    Mar 12, 2008
  4. cindy

    datagrid sort string (is representation of date) as a DATE

    cindy, Mar 31, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    213
    Steven Cheng[MSFT]
    Mar 31, 2006
  5. ruck
    Replies:
    10
    Views:
    1,286
Loading...

Share This Page